-
Notifications
You must be signed in to change notification settings - Fork 191
/
Copy pathdebugger.ts
107 lines (94 loc) · 2.47 KB
/
debugger.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { resetDebuggerCallback, setDebuggerCallback } from '@glimmer/runtime';
import { RenderTest } from '../render-test';
import { test } from '../test-decorator';
export class DebuggerSuite extends RenderTest {
static suiteName = 'Debugger';
afterEach() {
resetDebuggerCallback();
}
@test
'basic debugger statement'() {
let expectedContext = {
foo: 'bar',
a: {
b: true,
},
};
let callbackExecuted = 0;
setDebuggerCallback((context: any, get) => {
callbackExecuted++;
this.assert.strictEqual(context.foo, expectedContext.foo);
this.assert.strictEqual(get('foo'), expectedContext.foo);
});
this.render(
'{{#if this.a.b}}true{{debugger}}{{else}}false{{debugger}}{{/if}}',
expectedContext
);
this.assert.strictEqual(callbackExecuted, 1);
this.assertHTML('true');
this.assertStableRerender();
expectedContext = {
foo: 'baz',
a: {
b: false,
},
};
this.rerender(expectedContext);
this.assert.strictEqual(callbackExecuted, 2);
this.assertHTML('false');
this.assertStableNodes();
expectedContext = {
foo: 'bar',
a: {
b: true,
},
};
this.rerender(expectedContext);
this.assert.strictEqual(callbackExecuted, 3);
this.assertHTML('true');
this.assertStableNodes();
}
@test
'can get locals'() {
let expectedContext = {
foo: 'bar',
a: {
b: true,
},
};
let callbackExecuted = 0;
setDebuggerCallback((context: any, get) => {
callbackExecuted++;
this.assert.strictEqual(get('foo'), expectedContext.foo);
this.assert.strictEqual(get('bar'), expectedContext.foo);
this.assert.deepEqual(get('this'), context);
});
this.render(
'{{#let this.foo as |bar|}}{{#if this.a.b}}true{{debugger}}{{else}}false{{debugger}}{{/if}}{{/let}}',
expectedContext
);
this.assert.strictEqual(callbackExecuted, 1);
this.assertHTML('true');
this.assertStableRerender();
expectedContext = {
foo: 'baz',
a: {
b: false,
},
};
this.rerender(expectedContext);
this.assert.strictEqual(callbackExecuted, 2);
this.assertHTML('false');
this.assertStableNodes();
expectedContext = {
foo: 'bar',
a: {
b: true,
},
};
this.rerender(expectedContext);
this.assert.strictEqual(callbackExecuted, 3);
this.assertHTML('true');
this.assertStableNodes();
}
}