diff --git a/src/client/__mocks__/window.ts b/src/client/__mocks__/window.ts index 4eddf1c..cbe49b4 100644 --- a/src/client/__mocks__/window.ts +++ b/src/client/__mocks__/window.ts @@ -3,13 +3,22 @@ export const createObjectURL = jest.fn() export const revokeObjectURL = jest.fn() export class MediaStream { + getTracks() { + return [{ + stop: jest.fn(), + }, { + stop: jest.fn(), + }] + } getVideoTracks () { return [{ enabled: true, + stop: jest.fn(), }] } getAudioTracks () { return [{ + stop: jest.fn(), enabled: true, }] } diff --git a/src/client/actions/SocketActions.test.ts b/src/client/actions/SocketActions.test.ts index 6adaee4..2b5423a 100644 --- a/src/client/actions/SocketActions.test.ts +++ b/src/client/actions/SocketActions.test.ts @@ -8,6 +8,7 @@ import { EventEmitter } from 'events' import { createStore, Store, GetState } from '../store' import { ClientSocket } from '../socket' import { Dispatch } from 'redux' +import { MediaStream } from '../window' describe('SocketActions', () => { const roomName = 'bla' @@ -128,7 +129,13 @@ describe('SocketActions', () => { describe('stream', () => { it('adds a stream to streamStore', () => { - const stream = {} + const stream = { + getTracks() { + return [{ + stop: jest.fn(), + }] + }, + } peer.emit(constants.PEER_EVENT_STREAM, stream) expect(store.getState().streams).toEqual({ @@ -143,7 +150,7 @@ describe('SocketActions', () => { describe('close', () => { beforeEach(() => { - const stream = {} + const stream = new MediaStream() peer.emit(constants.PEER_EVENT_STREAM, stream) expect(store.getState().streams).toEqual({ b: { diff --git a/src/client/components/Notifications.tsx b/src/client/components/Notifications.tsx index c4ecf75..9fc93fb 100644 --- a/src/client/components/Notifications.tsx +++ b/src/client/components/Notifications.tsx @@ -23,14 +23,7 @@ export interface NotificationProps { const Notification = React.memo( function Notification(props: NotificationProps) { - const { dismiss, notification } = props - // React.useEffect(() => { - // const timeout = setTimeout(dismiss, props.timeout, notification.id) - // return () => { - // clearTimeout(timeout) - // dismiss(notification.id) - // } - // }, []) + const { notification } = props return (