-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #505 from glimmerjs/maybe-fix
[BUGFIX #484] ensure transactions are always.
- Loading branch information
Showing
2 changed files
with
34 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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { TestEnvironment } from "@glimmer/test-helpers"; | ||
|
||
QUnit.module('env'); | ||
|
||
QUnit.test('assert against nested transactions', assert => { | ||
let env = new TestEnvironment(); | ||
env.begin(); | ||
assert.throws(() => env.begin(), 'a glimmer transaction was begun, but one already exists. You may have a nested transaction'); | ||
}); | ||
|
||
QUnit.test('ensure commit cleans up when it can', assert => { | ||
let env = new TestEnvironment(); | ||
env.begin(); | ||
|
||
// ghetto stub | ||
Object.defineProperty(env, 'transaction', { | ||
get() { | ||
return { | ||
scheduledInstallManagers() : void { }, | ||
commit() : void { | ||
throw new Error('something failed'); | ||
} | ||
}; | ||
} | ||
}); | ||
|
||
assert.throws(() => env.commit(), 'something failed'); // commit failed | ||
|
||
// but a previous commit failing, does not cause a future transaction to fail to start | ||
env.begin(); | ||
}); |