-
-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Found issue with that Dexie.Promise.on('error') wasnt signaled for fa…
…iled transactionless operations. This unit test confirms that.
- Loading branch information
1 parent
3ab125f
commit e7f3275
Showing
1 changed file
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,9 +9,10 @@ db.on("populate", function (trans) { | |
users.add({ id: 1, first: "David", last: "Fahlander", username: "dfahlander", email: ["[email protected]", "[email protected]"], pets: ["dog"] }); | ||
users.add({ id: 2, first: "Karl", last: "Cedersköld", username: "kceder", email: ["[email protected]"], pets: [] }); | ||
}); | ||
db.on("error", function (e) { | ||
function dbOnErrorHandler (e) { | ||
ok(false, "An error bubbled out to the db.on('error'). Should not happen because all tests should catch their errors themselves. " + e); | ||
}); | ||
} | ||
db.on("error", dbOnErrorHandler); | ||
|
||
module("exception-handling", { | ||
setup: function () { | ||
|
@@ -24,6 +25,23 @@ module("exception-handling", { | |
} | ||
}); | ||
|
||
asyncTest("Uncaught promise should signal to Promise.on('error')", function(){ | ||
// We must not use finally or catch here because then we don't test what we should. | ||
var onErrorSignals = 0; | ||
function onerror(e) { | ||
++onErrorSignals; | ||
} | ||
Dexie.Promise.on('error', onerror); | ||
db.on('error').unsubscribe(dbOnErrorHandler); | ||
db.users.add({ id: 1 }); | ||
setTimeout(()=> { | ||
equal(onErrorSignals, 1, "Promise.on('error') should have been signaled"); | ||
db.on("error", dbOnErrorHandler); | ||
Dexie.Promise.on('error').unsubscribe(onerror); | ||
start(); | ||
}, 100); | ||
}); | ||
|
||
spawnedTest("transaction should abort on collection error", function*(){ | ||
yield db.transaction("rw", db.users, function*() { | ||
let id = yield db.users.add({id: 3, first: "Foo", last: "Bar", username: "foobar"}); | ||
|