diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-10-13 11:31:57 +0200 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-10-13 11:31:57 +0200 |
| commit | 992f7946dbe9004d88a331b97ea9e030701599ea (patch) | |
| tree | 858ef774e0751435f2b039af846cef4d29c37a0c /test/mocks | |
| parent | 8f5c5aa9a433a65d8a7f6f6d8e4211f5a82068f5 (diff) | |
| download | mullvadvpn-992f7946dbe9004d88a331b97ea9e030701599ea.tar.xz mullvadvpn-992f7946dbe9004d88a331b97ea9e030701599ea.zip | |
Move the auth flow into backend.js and write tests
Diffstat (limited to 'test/mocks')
| -rw-r--r-- | test/mocks/ipc.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test/mocks/ipc.js b/test/mocks/ipc.js index 8f0b82ba37..2672a431fd 100644 --- a/test/mocks/ipc.js +++ b/test/mocks/ipc.js @@ -1,20 +1,23 @@ // @flow -import type { IpcFacade, BackendState, IpcCredentials } from '../../app/lib/ipc-facade'; +import type { IpcFacade, BackendState } from '../../app/lib/ipc-facade'; interface MockIpc { sendNewState: (BackendState) => void; + killWebSocket: () => void; -getAccountData: *; -connect: *; -getAccount: *; + -auth: *; } export function newMockIpc() { const stateListeners = []; + const connectionCloseListeners = []; const mockIpc: IpcFacade & MockIpc = { - setCredentials: (_credentials: IpcCredentials) => {}, + setConnectionString: (_str: string) => {}, getAccountData: (accountToken) => { return new Promise(r => r({ accountToken: accountToken, @@ -60,6 +63,15 @@ export function newMockIpc() { l(state); } }, + auth: (_secret: string) => Promise.resolve(), + setCloseConnectionHandler: (listener: () => void) => { + connectionCloseListeners.push(listener); + }, + killWebSocket: () => { + for(const l of connectionCloseListeners) { + l(); + } + } }; return mockIpc; |
