forked from ucfopen/Obojobo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogo.test.js
More file actions
32 lines (28 loc) · 1.03 KB
/
Copy pathlogo.test.js
File metadata and controls
32 lines (28 loc) · 1.03 KB
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
import React from 'react'
import renderer from 'react-test-renderer'
import Logo from 'src/scripts/viewer/components/logo'
import rd from 'src/scripts/viewer/components/rd'
jest.mock('src/scripts/viewer/components/rd')
describe('Logo', () => {
test('renders correctly when inverted prop is true', () => {
const component = renderer.create(<Logo inverted />)
expect(component).toMatchSnapshot()
})
test('renders correctly when not inverted prop is false', () => {
const component = renderer.create(<Logo inverted={false} />)
expect(component).toMatchSnapshot()
})
test('onClick updates state and calls rd', () => {
const component = renderer.create(<Logo inverted />)
expect(component.getInstance().state.clicks).toBe(0)
expect(rd).not.toBeCalled()
for (let i = 0; i < 10; i++) {
component.getInstance().onClick()
}
expect(component.getInstance().state.clicks).toBe(10)
expect(rd).not.toBeCalled()
component.getInstance().onClick()
expect(component.getInstance().state.clicks).toBe(11)
expect(rd).toBeCalled()
})
})