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
|
|
|
|
|
2014-11-04 22:59:48 +00:00
|
|
|
/*
|
|
|
|
* global helpers for tests
|
|
|
|
*/
|
2014-11-16 21:19:51 +00:00
|
|
|
|
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() {
|
2018-07-25 22:02:37 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2018-11-08 00:53:41 +00:00
|
|
|
const idbReq = indexedDB.deleteDatabase('test');
|
2018-07-25 22:02:37 +00:00
|
|
|
idbReq.onsuccess = resolve;
|
|
|
|
idbReq.error = reject;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-04 00:12:57 +00:00
|
|
|
window.Events = {
|
|
|
|
getThemeSetting: () => 'light',
|
|
|
|
};
|
|
|
|
|
2015-04-16 01:02:44 +00:00
|
|
|
/* Delete the database before running any tests */
|
2018-07-25 22:02:37 +00:00
|
|
|
before(async () => {
|
2023-10-04 00:12:57 +00:00
|
|
|
await window.testUtilities.initialize();
|
2018-11-02 18:02:53 +00:00
|
|
|
await deleteIndexedDB();
|
2018-07-27 01:13:56 +00:00
|
|
|
await window.Signal.Data.removeAll();
|
2019-01-14 21:49:58 +00:00
|
|
|
await window.storage.fetch();
|
2018-07-25 22:02:37 +00:00
|
|
|
});
|
2018-04-03 15:39:08 +00:00
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
window.testUtilities.prepareTests();
|
|
|
|
delete window.testUtilities.prepareTests;
|
2023-10-04 00:12:57 +00:00
|
|
|
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();
|
|
|
|
})();
|
2023-03-02 18:43:25 +00:00
|
|
|
|
|
|
|
window.getPreferredSystemLocales = () => ['en'];
|
2023-11-07 01:02:13 +00:00
|
|
|
window.getLocaleOverride = () => null;
|