Fix broken App.test.tsx
This commit is contained in:
parent
3a5b07c218
commit
7009e53037
@ -22,19 +22,19 @@ extends React.PureComponent<NotificationProps> {
|
|||||||
const { notifications, max } = this.props
|
const { notifications, max } = this.props
|
||||||
return (
|
return (
|
||||||
<div className="notifications">
|
<div className="notifications">
|
||||||
<CSSTransition
|
{Object.keys(notifications).slice(-max).map(id => (
|
||||||
classNames='fade'
|
<CSSTransition
|
||||||
timeout={transitionTimeout}
|
key={id}
|
||||||
>
|
classNames='fade'
|
||||||
{Object.keys(notifications).slice(-max).map(id => (
|
timeout={transitionTimeout}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
className={classnames(notifications[id].type, 'notification')}
|
className={classnames(notifications[id].type, 'notification')}
|
||||||
key={id}
|
|
||||||
>
|
>
|
||||||
{notifications[id].message}
|
{notifications[id].message}
|
||||||
</div>
|
</div>
|
||||||
))}
|
</CSSTransition>
|
||||||
</CSSTransition>
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,13 +26,14 @@ describe('App', () => {
|
|||||||
state = {};
|
state = {};
|
||||||
(init as jest.Mock).mockReturnValue(initAction)
|
(init as jest.Mock).mockReturnValue(initAction)
|
||||||
|
|
||||||
dispatchSpy = jest.spyOn(store, 'dispatch')
|
|
||||||
window.HTMLMediaElement.prototype.play = jest.fn()
|
window.HTMLMediaElement.prototype.play = jest.fn()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
dispatchSpy.mockReset()
|
if (dispatchSpy) {
|
||||||
dispatchSpy.mockRestore()
|
dispatchSpy.mockReset()
|
||||||
|
dispatchSpy.mockRestore()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let node: Element
|
let node: Element
|
||||||
@ -42,11 +43,12 @@ describe('App', () => {
|
|||||||
state,
|
state,
|
||||||
applyMiddleware(...middlewares),
|
applyMiddleware(...middlewares),
|
||||||
)
|
)
|
||||||
|
dispatchSpy = jest.spyOn(store, 'dispatch')
|
||||||
const div = document.createElement('div')
|
const div = document.createElement('div')
|
||||||
await new Promise<HTMLDivElement>(resolve => {
|
node = await new Promise<HTMLDivElement>(resolve => {
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<div ref={app => resolve(app!)}>
|
<div ref={div => resolve(div!)}>
|
||||||
<App />
|
<App />
|
||||||
</div>
|
</div>
|
||||||
</Provider>,
|
</Provider>,
|
||||||
@ -56,8 +58,8 @@ describe('App', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('render', () => {
|
describe('render', () => {
|
||||||
it('renders without issues', () => {
|
it('renders without issues', async () => {
|
||||||
render()
|
await render()
|
||||||
expect(node).toBeTruthy()
|
expect(node).toBeTruthy()
|
||||||
expect((init as jest.Mock).mock.calls.length).toBe(1)
|
expect((init as jest.Mock).mock.calls.length).toBe(1)
|
||||||
})
|
})
|
||||||
@ -65,7 +67,7 @@ describe('App', () => {
|
|||||||
|
|
||||||
describe('state', () => {
|
describe('state', () => {
|
||||||
let alert: Alert
|
let alert: Alert
|
||||||
beforeEach(() => {
|
beforeEach(async () => {
|
||||||
state.streams = {
|
state.streams = {
|
||||||
test: {
|
test: {
|
||||||
mediaStream: new MediaStream(),
|
mediaStream: new MediaStream(),
|
||||||
@ -82,18 +84,20 @@ describe('App', () => {
|
|||||||
type: 'warning',
|
type: 'warning',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
state.alerts = [{
|
alert = {
|
||||||
dismissable: true,
|
dismissable: true,
|
||||||
action: 'Dismiss',
|
action: 'Dismiss',
|
||||||
message: 'test alert',
|
message: 'test alert',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
}]
|
}
|
||||||
render()
|
state.alerts = [alert]
|
||||||
|
await render()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('alerts', () => {
|
describe('alerts', () => {
|
||||||
it('can be dismissed', () => {
|
it('can be dismissed', () => {
|
||||||
const dismiss = node.querySelector('.action-alert-dismiss')!
|
const dismiss = node.querySelector('.action-alert-dismiss')!
|
||||||
|
dispatchSpy.mockReset()
|
||||||
TestUtils.Simulate.click(dismiss)
|
TestUtils.Simulate.click(dismiss)
|
||||||
expect(dispatchSpy.mock.calls).toEqual([[{
|
expect(dispatchSpy.mock.calls).toEqual([[{
|
||||||
type: constants.ALERT_DISMISS,
|
type: constants.ALERT_DISMISS,
|
||||||
@ -104,6 +108,7 @@ describe('App', () => {
|
|||||||
|
|
||||||
describe('video', () => {
|
describe('video', () => {
|
||||||
it('can be activated', () => {
|
it('can be activated', () => {
|
||||||
|
dispatchSpy.mockReset()
|
||||||
const video = node.querySelector('video')!
|
const video = node.querySelector('video')!
|
||||||
TestUtils.Simulate.click(video)
|
TestUtils.Simulate.click(video)
|
||||||
expect(dispatchSpy.mock.calls).toEqual([[{
|
expect(dispatchSpy.mock.calls).toEqual([[{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user