Use SignalContext instead of SignalWindow

This commit is contained in:
Josh Perez 2021-10-07 19:28:47 -04:00 committed by GitHub
parent a70a8a88d6
commit 75dab30367
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 180 additions and 231 deletions

View file

@ -6,8 +6,8 @@
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const { Crypto } = require('../ts/context/Crypto');
const { setEnvironment, Environment } = require('../ts/environment');
const { Context: SignalContext } = require('../ts/context');
const { isValidGuid } = require('../ts/util/isValidGuid');
chai.use(chaiAsPromised);
@ -18,8 +18,8 @@ const storageMap = new Map();
// To replicate logic we have on the client side
global.window = {
SignalContext: undefined,
SignalWindow: {
SignalContext: {
crypto: new Crypto(),
log: {
info: (...args) => console.log(...args),
warn: (...args) => console.warn(...args),
@ -34,21 +34,6 @@ global.window = {
isValidGuid,
};
const fakeIPC = {
sendSync(channel) {
// See `ts/context/NativeThemeListener.ts`
if (channel === 'native-theme:init') {
return { shouldUseDarkColors: true };
}
throw new Error(`Unsupported sendSync channel: ${channel}`);
},
on() {},
};
global.window.SignalContext = new SignalContext(fakeIPC);
// For ducks/network.getEmptyState()
global.navigator = {};
global.WebSocket = {};