2021-01-06 17:23:15 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-01-06 15:41:43 +00:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
2021-05-28 19:11:19 +00:00
|
|
|
const chai = require('chai');
|
|
|
|
const chaiAsPromised = require('chai-as-promised');
|
|
|
|
|
2021-03-04 20:01:34 +00:00
|
|
|
const ByteBuffer = require('../components/bytebuffer/dist/ByteBufferAB.js');
|
2021-04-09 16:19:38 +00:00
|
|
|
const Long = require('../components/long/dist/Long.js');
|
2021-02-04 19:54:03 +00:00
|
|
|
const { setEnvironment, Environment } = require('../ts/environment');
|
|
|
|
|
2021-05-28 19:11:19 +00:00
|
|
|
chai.use(chaiAsPromised);
|
|
|
|
|
2021-04-05 20:44:02 +00:00
|
|
|
setEnvironment(Environment.Test);
|
2021-02-04 19:54:03 +00:00
|
|
|
|
2021-05-28 19:11:19 +00:00
|
|
|
const storageMap = new Map();
|
|
|
|
|
2021-01-06 15:41:43 +00:00
|
|
|
// To replicate logic we have on the client side
|
|
|
|
global.window = {
|
|
|
|
log: {
|
|
|
|
info: (...args) => console.log(...args),
|
|
|
|
warn: (...args) => console.warn(...args),
|
|
|
|
error: (...args) => console.error(...args),
|
|
|
|
},
|
|
|
|
i18n: key => `i18n(${key})`,
|
2021-03-04 20:01:34 +00:00
|
|
|
dcodeIO: {
|
|
|
|
ByteBuffer,
|
2021-04-09 16:19:38 +00:00
|
|
|
Long,
|
2021-03-04 20:01:34 +00:00
|
|
|
},
|
2021-05-28 19:11:19 +00:00
|
|
|
storage: {
|
|
|
|
get: key => storageMap.get(key),
|
|
|
|
put: async (key, value) => storageMap.set(key, value),
|
|
|
|
},
|
2021-01-06 15:41:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// For ducks/network.getEmptyState()
|
|
|
|
global.navigator = {};
|
|
|
|
global.WebSocket = {};
|