forked from signalapp/Signal-Desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-test-node.js
46 lines (37 loc) · 1.09 KB
/
setup-test-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable no-console */
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const { Crypto } = require('../ts/context/Crypto');
const { setEnvironment, Environment } = require('../ts/environment');
chai.use(chaiAsPromised);
setEnvironment(Environment.Test);
const storageMap = new Map();
// To replicate logic we have on the client side
global.window = {
Date,
performance,
SignalContext: {
crypto: new Crypto(),
log: {
info: (...args) => console.log(...args),
warn: (...args) => console.warn(...args),
error: (...args) => console.error(...args),
},
},
i18n: key => `i18n(${key})`,
storage: {
get: key => storageMap.get(key),
put: async (key, value) => storageMap.set(key, value),
},
};
// For ducks/network.getEmptyState()
global.navigator = {};
global.WebSocket = {};
// For GlobalAudioContext.tsx
/* eslint max-classes-per-file: ["error", 2] */
global.AudioContext = class {};
global.Audio = class {
addEventListener() {}
};