-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update jest tests using react-test-renderer
ReactTestUtils.render is deprecated: facebook/react#25446 Also, the Xhr tests were failing with some node-fetch errors - I think it's fine to just remove these as they weren't actually asserting any business logic.
- Loading branch information
Showing
7 changed files
with
61 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
build | ||
.jshintignore | ||
.jshintrc | ||
__tests__/__snapshots__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,15 @@ | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import ReactTestUtils from 'react-dom/test-utils'; | ||
import renderer from 'react-test-renderer'; | ||
import JuxtaposeApplication from '../src/JuxtaposeApplication.jsx'; | ||
import {mediaTrackData, textTrackData} from '../src/data.js'; | ||
|
||
describe('JuxtaposeApplication.getItem', () => { | ||
describe('JuxtaposeApplication', () => { | ||
it('returns the expected output', () => { | ||
const app = ReactTestUtils.renderIntoDocument( | ||
<JuxtaposeApplication /> | ||
const component = renderer.create( | ||
<JuxtaposeApplication readOnly={false} /> | ||
); | ||
app.setState({ | ||
'mediaTrack': mediaTrackData, | ||
'textTrack': textTrackData | ||
}) | ||
expect(app.getItem(null)).toBeNull; | ||
|
||
expect(app.getItem(['txt', 0])).toEqual({ | ||
'key': 0, | ||
'start_time': 5, | ||
'end_time': 40, | ||
'type': 'txt', | ||
'source': 'Lorem ipsum dolor sit amet, consectetur adipiscing ' + | ||
'elit, sed do eiusmod tempor incididunt ut labore et ' + | ||
'dolore magna aliqua. Ut enim ad minim' | ||
}); | ||
expect(app.getItem(['txt', 1])).toEqual({ | ||
'key': 1, | ||
'start_time': 45, | ||
'end_time': 55, | ||
'type': 'txt', | ||
'source': 'Duis aute irure dolor in reprehenderit in voluptate ' + | ||
'velit esse cillum dolore eu fugiat nulla pariatur. ' + | ||
'Excepteur sint occaecat cupidatat non' | ||
}); | ||
expect(app.getItem(['media', 3])).toEqual({ | ||
'key': 3, | ||
'id': 4, | ||
'start_time': 38, | ||
'end_time': 55, | ||
'type': 'img', | ||
'source': 'static/img/image.jpg' | ||
}); | ||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import ReactTestUtils from 'react-dom/test-utils'; | ||
import renderer from 'react-test-renderer'; | ||
import PlayButton from '../src/PlayButton.jsx'; | ||
|
||
describe('PlayButton', () => { | ||
it('changes state after click', () => { | ||
let onClick = function() {}; | ||
it('changes state after click', () => { | ||
const onClick = jest.fn(); | ||
const component = renderer.create( | ||
<PlayButton playing={false} onClick={onClick} /> | ||
); | ||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
|
||
const playButton = ReactTestUtils.renderIntoDocument( | ||
<PlayButton playing={false} onClick={onClick} /> | ||
); | ||
expect(playButton.props.playing).toBe(false); | ||
|
||
// TODO: assert that onClick was called | ||
renderer.act(() => { | ||
tree.props.onClick(); | ||
}); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,20 @@ | ||
/* eslint-env jest */ | ||
|
||
import React from 'react'; | ||
import ReactTestUtils from 'react-dom/test-utils'; | ||
import renderer from 'react-test-renderer'; | ||
import TimelineRuler from '../src/TimelineRuler.jsx'; | ||
|
||
describe('TimelineRuler', () => { | ||
it('can be initialized', () => { | ||
const timelineRuler = ReactTestUtils.renderIntoDocument( | ||
<TimelineRuler hovering={false} duration={0} />); | ||
expect(timelineRuler.props.duration).toBe(0); | ||
const component = renderer.create( | ||
<TimelineRuler hovering={false} duration={0} />); | ||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
it('calculates correct offsets for timeline ticks', () => { | ||
const timelineRuler = ReactTestUtils.renderIntoDocument( | ||
<TimelineRuler hovering={false} duration={0} />); | ||
|
||
expect(timelineRuler.generateTicks(0)).toEqual([[100, 0]]); | ||
expect(timelineRuler.generateTicks(8889)).toEqual([ | ||
[0, 0], | ||
[14.962312971087863, 1330], | ||
[29.924625942175727, 2660], | ||
[44.886938913263585, 3990], | ||
[59.84925188435145, 5320], | ||
[74.8115648554393, 6650], | ||
[89.77387782652717, 7980], | ||
[100, 8889] | ||
]); | ||
expect(timelineRuler.generateTicks(37)).toEqual([ | ||
[0, 0], | ||
[81.08108108108108, 30], | ||
[100, 37] | ||
]); | ||
const component = renderer.create( | ||
<TimelineRuler hovering={false} duration={0} />); | ||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters