signal-desktop/test/test.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2014 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
/*
* global helpers for tests
*/
2023-01-13 00:24:59 +00:00
mocha.setup('bdd');
2022-09-01 18:56:25 +00:00
mocha.setup({ timeout: 10000 });
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;
});
}
window.Events = {
getThemeSetting: () => 'light',
};
/* Delete the database before running any tests */
before(async () => {
await window.testUtilities.initialize();
2018-11-02 18:02:53 +00:00
await deleteIndexedDB();
await window.Signal.Data.removeAll();
2019-01-14 21:49:58 +00:00
await window.storage.fetch();
});
2023-01-13 00:24:59 +00:00
window.testUtilities.prepareTests();
delete window.testUtilities.prepareTests;
window.textsecure.storage.protocol = window.getSignalProtocolStore();
2023-01-13 00:24:59 +00:00
!(function () {
const passed = [];
const failed = [];
class Reporter extends Mocha.reporters.HTML {
constructor(runner, options) {
super(runner, options);
runner.on('pass', test => passed.push(test.fullTitle()));
runner.on('fail', (test, error) => {
failed.push({
testName: test.fullTitle(),
error: error?.stack || String(error),
});
});
runner.on('end', () =>
window.testUtilities.onComplete({ passed, failed })
);
}
}
mocha.reporter(Reporter);
mocha.run();
})();
window.getPreferredSystemLocales = () => ['en'];