Skip to content

Commit

Permalink
Tests that db.open() error is catched on node when missing indexedDB …
Browse files Browse the repository at this point in the history
…api.
  • Loading branch information
dfahlander committed Mar 21, 2016
1 parent d03c77f commit 21cdf2e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/tests-open.js
@@ -1,5 +1,6 @@
import Dexie from 'dexie';
import {module, stop, start, asyncTest, equal, ok} from 'QUnit';
import {spawnedTest} from './dexie-unittest-utils';

const async = Dexie.async;

Expand All @@ -17,6 +18,26 @@ module("open", {
}
});

spawnedTest("Using db on node should be rejected with MissingAPIError", function*(){
let db = new Dexie('TestDB', {
indexedDB: undefined,
IDBKeyRange: undefined
});
db.version(1).stores({foo: 'bar'});
try {
yield db.foo.toArray();
ok(false, "Should not get any result because API is missing.");
} catch (e) {
ok(e instanceof Dexie.MissingAPIError, "Should get MissingAPIError. Got: " + e.name);
}
try {
yield db.open();
} catch (e) {
ok(e instanceof Dexie.MissingAPIError, "Should get MissingAPIError. Got: " + e.name);
}

});

asyncTest("open, add and query data without transaction", 6, function () {
var db = new Dexie("TestDB");
db.version(1).stores({ employees: "++id,first,last" });
Expand Down

0 comments on commit 21cdf2e

Please sign in to comment.