2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-06 17:23:15 +00:00
|
|
|
// 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-10-07 23:28:47 +00:00
|
|
|
const { Crypto } = require('../ts/context/Crypto');
|
2021-02-04 19:54:03 +00:00
|
|
|
const { setEnvironment, Environment } = require('../ts/environment');
|
2023-07-31 16:23:19 +00:00
|
|
|
const { HourCyclePreference } = require('../ts/types/I18N');
|
2021-02-04 19:54:03 +00:00
|
|
|
|
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 = {
|
2022-02-25 23:59:27 +00:00
|
|
|
Date,
|
|
|
|
performance,
|
2021-10-07 23:28:47 +00:00
|
|
|
SignalContext: {
|
|
|
|
crypto: new Crypto(),
|
2021-09-17 18:27:53 +00:00
|
|
|
log: {
|
|
|
|
info: (...args) => console.log(...args),
|
|
|
|
warn: (...args) => console.warn(...args),
|
|
|
|
error: (...args) => console.error(...args),
|
|
|
|
},
|
2023-08-07 20:28:09 +00:00
|
|
|
getResolvedMessagesLocale: () => 'en',
|
|
|
|
getResolvedMessagesLocaleDirection: () => 'ltr',
|
|
|
|
getHourCyclePreference: () => HourCyclePreference.UnknownPreference,
|
|
|
|
getPreferredSystemLocales: () => ['en'],
|
2023-11-07 01:02:13 +00:00
|
|
|
getLocaleOverride: () => null,
|
2021-01-06 15:41:43 +00:00
|
|
|
},
|
|
|
|
i18n: key => `i18n(${key})`,
|
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 = {};
|
2022-09-15 20:10:46 +00:00
|
|
|
|
|
|
|
// For GlobalAudioContext.tsx
|
|
|
|
/* eslint max-classes-per-file: ["error", 2] */
|
|
|
|
global.AudioContext = class {};
|
|
|
|
global.Audio = class {
|
2024-01-24 00:11:12 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
2023-02-24 23:18:57 +00:00
|
|
|
pause() {}
|
2024-01-24 00:11:12 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
2022-09-15 20:10:46 +00:00
|
|
|
addEventListener() {}
|
|
|
|
};
|