-
Notifications
You must be signed in to change notification settings - Fork 187
/
env-test.ts
52 lines (40 loc) · 1.3 KB
/
env-test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { castToSimple } from '@glimmer/util';
import { EnvironmentImpl } from '@glimmer/runtime';
QUnit.module('[integration] env');
QUnit.test('assert against nested transactions', (assert) => {
let env = new EnvironmentImpl(
{ document: castToSimple(document) },
{
onTransactionCommit() {},
scheduleEffects(_phase, callback) {
callback();
},
isInteractive: true,
enableDebugTooling: false,
}
);
env.begin();
assert.throws(
() => env.begin(),
'A glimmer transaction was begun, but one already exists. You may have a nested transaction, possibly caused by an earlier runtime exception while rendering. Please check your console for the stack trace of any prior exceptions.'
);
});
QUnit.test('ensure commit cleans up when it can', (assert) => {
let env = new EnvironmentImpl(
{ document: castToSimple(document) },
{
onTransactionCommit() {
throw new Error('something failed');
},
scheduleEffects(_phase, callback) {
callback();
},
isInteractive: true,
enableDebugTooling: false,
}
);
env.begin();
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();
});