From 0075d938794364266ccf56119f27ca3e2e66144c Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 13 Nov 2019 21:34:14 -0300 Subject: [PATCH] Fix simple-peer mock --- __mocks__/simple-peer.js | 12 ------------ src/__mocks__/simple-peer.ts | 14 ++++++++++++++ src/client/actions/CallActions.ts | 9 ++++----- src/client/actions/PeerActions.test.ts | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 __mocks__/simple-peer.js create mode 100644 src/__mocks__/simple-peer.ts diff --git a/__mocks__/simple-peer.js b/__mocks__/simple-peer.js deleted file mode 100644 index b274693..0000000 --- a/__mocks__/simple-peer.js +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable */ -import EventEmitter from 'events' -const Peer = jest.fn().mockImplementation(() => { - const peer = new EventEmitter() - peer.destroy = jest.fn() - peer.signal = jest.fn() - peer.send = jest.fn() - Peer.instances.push(peer) - return peer -}) -Peer.instances = [] -export default Peer diff --git a/src/__mocks__/simple-peer.ts b/src/__mocks__/simple-peer.ts new file mode 100644 index 0000000..5005806 --- /dev/null +++ b/src/__mocks__/simple-peer.ts @@ -0,0 +1,14 @@ +/* eslint-disable */ +import EventEmitter from 'events' + +const Peer = jest.fn().mockImplementation(() => { + const peer = new EventEmitter(); + (peer as any).destroy = jest.fn(); + (peer as any).signal = jest.fn(); + (peer as any).send = jest.fn(); + (Peer as any).instances.push(peer) + return peer +}); + +(Peer as any).instances = [] +export default Peer diff --git a/src/client/actions/CallActions.ts b/src/client/actions/CallActions.ts index 18ca3ed..3201db0 100644 --- a/src/client/actions/CallActions.ts +++ b/src/client/actions/CallActions.ts @@ -1,11 +1,10 @@ +import * as constants from '../constants' +import socket from '../socket' +import { Dispatch, ThunkResult } from '../store' +import { callId, getUserMedia } from '../window' import * as NotifyActions from './NotifyActions' import * as SocketActions from './SocketActions' import * as StreamActions from './StreamActions' -import * as constants from '../constants' -import socket from '../socket' -import { callId, getUserMedia } from '../window' -import { Dispatch, GetState, ThunkResult } from '../store' -import { makeAction } from '../async' export interface InitAction { type: 'INIT' diff --git a/src/client/actions/PeerActions.test.ts b/src/client/actions/PeerActions.test.ts index 233aefb..6b01ac4 100644 --- a/src/client/actions/PeerActions.test.ts +++ b/src/client/actions/PeerActions.test.ts @@ -111,7 +111,7 @@ describe('PeerActions', () => { expect(messages[messages.length - 1]).toEqual({ userId: 'user2', timestamp: jasmine.any(String), - image: null, + image: undefined, message: 'test', }) })