Tests: delete indexeddbs after running
This commit is contained in:
parent
59da904353
commit
5ff59b0c23
2 changed files with 40 additions and 6 deletions
|
@ -7,7 +7,7 @@ var q = require('q');
|
|||
* name to stdout.
|
||||
* @param {Mocha.Context} context The test context
|
||||
*/
|
||||
module.exports.beforeEach = function(context) {
|
||||
export function beforeEach(context) {
|
||||
var desc = context.currentTest.fullTitle();
|
||||
console.log();
|
||||
console.log(desc);
|
||||
|
@ -16,13 +16,40 @@ module.exports.beforeEach = function(context) {
|
|||
// some tests store things in localstorage. Improve independence of tests
|
||||
// by making sure that they don't inherit any old state.
|
||||
window.localStorage.clear();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if the current environment supports webrtc
|
||||
*/
|
||||
module.exports.browserSupportsWebRTC = function() {
|
||||
export function browserSupportsWebRTC() {
|
||||
var n = global.window.navigator;
|
||||
return n.getUserMedia || n.webkitGetUserMedia ||
|
||||
n.mozGetUserMedia;
|
||||
};
|
||||
}
|
||||
|
||||
export function deleteIndexedDB(dbName) {
|
||||
return new q.Promise((resolve, reject) => {
|
||||
if (!window.indexedDB) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Removing indexeddb instance: ${dbName}`);
|
||||
const req = window.indexedDB.deleteDatabase(dbName);
|
||||
|
||||
req.onblocked = () => {
|
||||
console.log(`can't yet delete indexeddb because it is open elsewhere`);
|
||||
};
|
||||
|
||||
req.onerror = (ev) => {
|
||||
reject(new Error(
|
||||
"unable to delete indexeddb: " + ev.target.error,
|
||||
));
|
||||
};
|
||||
|
||||
req.onsuccess = () => {
|
||||
console.log(`Removed indexeddb instance: ${dbName}`);
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue