Delete MeteorDynamicImportCache database before running tests.

Also run the tests a third time without deleting the database, to exercise
the caching logic.
This commit is contained in:
Ben Newman
2017-03-04 16:14:56 -05:00
parent f9de0a7b65
commit ae59532f12
2 changed files with 22 additions and 0 deletions

View File

@@ -1,6 +1,21 @@
import assert from "assert";
describe("dynamic import(...)", function () {
if (global.indexedDB) {
const saveCache = process.env.METEOR_SAVE_DYNAMIC_IMPORT_CACHE;
if (! (saveCache && JSON.parse(saveCache))) {
it("cleared the IndexedDB cache", function () {
return new Promise((resolve, reject) => {
const deleteRequest =
global.indexedDB.deleteDatabase("MeteorDynamicImportCache");
deleteRequest.onerror =
deleteRequest.onblocked =
deleteRequest.onsuccess = resolve;
});
});
}
}
it("import same module both statically and dynamically", function () {
import moment from "moment";
return import("./imports/date").then(date => {

View File

@@ -13,6 +13,13 @@ selftest.define("dynamic import(...) in production", function () {
s.cd("dynamic-import-test-app-prod", run.bind(s, true));
});
selftest.define("dynamic import(...) with cache", function () {
const s = new Sandbox();
s.createApp("dynamic-import-test-app-cache", "dynamic-import");
s.set("METEOR_SAVE_DYNAMIC_IMPORT_CACHE", "true");
s.cd("dynamic-import-test-app-cache", run.bind(s, true));
});
function run(isProduction) {
const sandbox = this;
const args = [