signal-desktop/test/test.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2014-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2021-12-09 08:06:04 +00:00
/* global Whisper, _, Backbone */
// Override the database id.
2018-04-27 21:25:04 +00:00
window.Whisper = window.Whisper || {};
window.Whisper.Database = window.Whisper.Database || {};
Whisper.Database.id = 'test';
/*
* global helpers for tests
*/
2018-11-02 18:02:53 +00:00
function deleteIndexedDB() {
return new Promise((resolve, reject) => {
const idbReq = indexedDB.deleteDatabase('test');
idbReq.onsuccess = resolve;
idbReq.error = reject;
});
}
/* Delete the database before running any tests */
before(async () => {
window.Signal.Util.MessageController.install();
2018-11-02 18:02:53 +00:00
await deleteIndexedDB();
2021-03-04 21:44:57 +00:00
try {
window.SignalContext.log.info('Initializing SQL in renderer');
const isTesting = true;
2021-10-07 18:16:51 +00:00
await window.Signal.Data.startInRenderer(isTesting);
window.SignalContext.log.info('SQL initialized in renderer');
2021-03-04 21:44:57 +00:00
} catch (err) {
window.SignalContext.log.error(
2021-03-04 21:44:57 +00:00
'SQL failed to initialize',
err && err.stack ? err.stack : err
);
}
2021-09-15 18:45:22 +00:00
await window.Signal.Util.initializeMessageCounter();
await window.Signal.Data.removeAll();
2019-01-14 21:49:58 +00:00
await window.storage.fetch();
});
2019-01-14 21:49:58 +00:00
window.Whisper = window.Whisper || {};
window.Whisper.events = _.clone(Backbone.Events);