Fix broken tests after update
This commit is contained in:
parent
5e39318cd9
commit
6d92c1add3
@ -1,5 +1,5 @@
|
|||||||
import EventEmitter from 'events'
|
import EventEmitter from 'events'
|
||||||
const Peer = jest.genMockFunction().mockImplementation(() => {
|
const Peer = jest.fn().mockImplementation(() => {
|
||||||
let peer = new EventEmitter()
|
let peer = new EventEmitter()
|
||||||
peer.destroy = jest.fn()
|
peer.destroy = jest.fn()
|
||||||
peer.signal = jest.fn()
|
peer.signal = jest.fn()
|
||||||
|
|||||||
@ -22,6 +22,7 @@ describe('App', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
init.mockReturnValue(initAction)
|
init.mockReturnValue(initAction)
|
||||||
state = reducers()
|
state = reducers()
|
||||||
|
window.HTMLMediaElement.prototype.play = jest.fn()
|
||||||
})
|
})
|
||||||
|
|
||||||
let component, node, store
|
let component, node, store
|
||||||
|
|||||||
11
src/client/__tests__/middlewares-test.js
Normal file
11
src/client/__tests__/middlewares-test.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import logger from 'redux-logger'
|
||||||
|
import { create } from '../middlewares.js'
|
||||||
|
|
||||||
|
describe('store', () => {
|
||||||
|
|
||||||
|
it('should load logger middleware', () => {
|
||||||
|
expect(create(true)).toContain(logger)
|
||||||
|
expect(create(false)).not.toContain(logger)
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
@ -1,11 +0,0 @@
|
|||||||
window.localStorage = { log: true }
|
|
||||||
import logger from 'redux-logger'
|
|
||||||
const store = require('../store.js')
|
|
||||||
|
|
||||||
describe('store', () => {
|
|
||||||
|
|
||||||
it('should load logger middleware', () => {
|
|
||||||
expect(store.middlewares.some(m => m === logger)).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
@ -27,7 +27,7 @@ describe('reducers/alerts', () => {
|
|||||||
|
|
||||||
describe('init', () => {
|
describe('init', () => {
|
||||||
|
|
||||||
it('calls handshake.init when connected & got camera stream', done => {
|
it('calls handshake.init when connected & got camera stream', async () => {
|
||||||
const promise = store.dispatch(CallActions.init())
|
const promise = store.dispatch(CallActions.init())
|
||||||
socket.emit('connect')
|
socket.emit('connect')
|
||||||
expect(store.getActions()).toEqual([{
|
expect(store.getActions()).toEqual([{
|
||||||
@ -40,18 +40,16 @@ describe('reducers/alerts', () => {
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
promise.then(() => {
|
await promise
|
||||||
expect(SocketActions.handshake.mock.calls).toEqual([[{
|
expect(SocketActions.handshake.mock.calls).toEqual([[{
|
||||||
socket,
|
socket,
|
||||||
roomName: callId,
|
roomName: callId,
|
||||||
stream: getUserMedia.stream
|
stream: getUserMedia.stream
|
||||||
}]])
|
}]])
|
||||||
})
|
|
||||||
.then(done)
|
|
||||||
.catch(done.fail)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('calls dispatches disconnect message on disconnect', done => {
|
it('calls dispatches disconnect message on disconnect', async () => {
|
||||||
|
|
||||||
const promise = store.dispatch(CallActions.init())
|
const promise = store.dispatch(CallActions.init())
|
||||||
socket.emit('connect')
|
socket.emit('connect')
|
||||||
socket.emit('disconnect')
|
socket.emit('disconnect')
|
||||||
@ -72,19 +70,15 @@ describe('reducers/alerts', () => {
|
|||||||
type: 'error'
|
type: 'error'
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
promise.then(done).catch(done.fail)
|
await promise
|
||||||
})
|
})
|
||||||
|
|
||||||
it('dispatches alert when failed to get media stream', done => {
|
it('dispatches alert when failed to get media stream', async () => {
|
||||||
getUserMedia.fail(true)
|
getUserMedia.fail(true)
|
||||||
const promise = store.dispatch(CallActions.init())
|
const promise = store.dispatch(CallActions.init())
|
||||||
socket.emit('connect')
|
socket.emit('connect')
|
||||||
promise
|
const result = await promise
|
||||||
.then(result => {
|
expect(result.value).toBe(null)
|
||||||
expect(result.value).toBe(null)
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
.catch(done.fail)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@ -54,7 +54,7 @@ describe('components/Video', () => {
|
|||||||
component.setState({
|
component.setState({
|
||||||
stream: { url: 'test', mediaStream }
|
stream: { url: 'test', mediaStream }
|
||||||
})
|
})
|
||||||
expect(video.refs.video.src).toBe('test')
|
expect(video.refs.video.src).toBe('http://localhost/test')
|
||||||
component.setState({
|
component.setState({
|
||||||
stream: { url: 'test', mediaStream }
|
stream: { url: 'test', mediaStream }
|
||||||
})
|
})
|
||||||
|
|||||||
@ -8,14 +8,14 @@ describe('server/socket', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
socket = new EventEmitter()
|
socket = new EventEmitter()
|
||||||
socket.id = 'socket0'
|
socket.id = 'socket0'
|
||||||
socket.join = jest.genMockFunction()
|
socket.join = jest.fn()
|
||||||
socket.leave = jest.genMockFunction()
|
socket.leave = jest.fn()
|
||||||
rooms = {}
|
rooms = {}
|
||||||
|
|
||||||
io = {}
|
io = {}
|
||||||
io.in = io.to = jest.genMockFunction().mockImplementation(room => {
|
io.in = io.to = jest.fn().mockImplementation(room => {
|
||||||
return (rooms[room] = rooms[room] || {
|
return (rooms[room] = rooms[room] || {
|
||||||
emit: jest.genMockFunction()
|
emit: jest.fn()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -39,8 +39,8 @@ describe('server/socket', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.leave = jest.genMockFunction()
|
socket.leave = jest.fn()
|
||||||
socket.join = jest.genMockFunction()
|
socket.join = jest.fn()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should be a function', () => {
|
it('should be a function', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user