Files
threshold-ui/addons/api/addon-test-support/helpers/indexed-db.js
T

35 lines
818 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
2024-02-05 15:59:58 -05:00
/**
* This test helper can help set up and cleanup the database in your tests.
*
* ```js
* import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
*
* module('Acceptance | my test', function(hooks) {
* setupApplicationTest(hooks);
* setupIndexedDb(hooks);
*
* // add your actual tests here
* });
* ```
*
* @param hooks
*/
export function setupIndexedDb(hooks) {
hooks.beforeEach(async function () {
2024-02-05 15:59:58 -05:00
const indexedDb = this.owner.lookup('service:indexed-db');
await indexedDb.setup(`test-indexed-db-${Date.now()}`);
2024-02-05 15:59:58 -05:00
});
hooks.afterEach(async function () {
const indexedDb = this.owner.lookup('service:indexed-db');
await indexedDb.db.delete();
});
}
export default setupIndexedDb;