forked from ReactTooltip/react-tooltip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
globalMethods.test.js
34 lines (31 loc) · 1023 Bytes
/
globalMethods.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* For Standard.js lint checking */
/* eslint-env mocha */
import React from 'react'
import { mount } from 'enzyme'
import chai, { expect } from 'chai'
import chaiEnzyme from 'chai-enzyme'
import sinon from 'sinon'
import ReactTooltip from '../src'
/* Initial test tools */
chai.use(chaiEnzyme())
describe('Global methods', () => {
it('should be hided by invoking ReactTooltip.hide', done => {
const wrapper = mount(<ReactTooltip />)
wrapper.setState({ show: true })
sinon.spy(ReactTooltip.prototype, 'hideTooltip')
ReactTooltip.hide()
setImmediate(() => {
expect(ReactTooltip.prototype.hideTooltip.calledOnce).to.equal(true)
expect(wrapper).to.have.state('show', false)
done()
})
})
it('should invoke globalRebuild when using ReactTooltip.rebuild', done => {
sinon.spy(ReactTooltip.prototype, 'globalRebuild')
ReactTooltip.rebuild()
setImmediate(() => {
expect(ReactTooltip.prototype.globalRebuild.calledOnce).to.equal(true)
done()
})
})
})