-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathi-n-u-r-test.ts
71 lines (62 loc) · 2.21 KB
/
i-n-u-r-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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { castToSimple } from '@glimmer/debug-util';
import { JitRenderDelegate, RenderTest } from '@glimmer-workspace/integration-tests';
import { module } from './support';
// "I-N-U-R" cycle
// initial render -> no-op rerender -> update(s) via mutation(s) -> reset via replacement
module('Render Tests: I-N-U-R', ({ test }) => {
let doc = castToSimple(document);
test('Can set properties', (assert) => {
new (class extends RenderTest {
constructor(delegate: JitRenderDelegate) {
super(delegate);
this.setProperties({ foo: 'bar' });
assert.strictEqual(this.context['foo'], 'bar');
}
})(new JitRenderDelegate());
});
test('Can take basic snapshots', (assert) => {
let div = doc.createElement('div');
let text = doc.createTextNode('Foo');
div.appendChild(text);
new (class extends RenderTest {
override element = div;
constructor(delegate: JitRenderDelegate) {
super(delegate);
let snapShot = this.takeSnapshot();
assert.deepEqual(snapShot, [text, 'up']);
}
})(new JitRenderDelegate());
});
test('Can take nested snapshots', (assert) => {
let div = doc.createElement('div');
let p = doc.createElement('p');
let text = doc.createTextNode('Foo');
p.appendChild(text);
div.appendChild(p);
new (class extends RenderTest {
override element = div;
constructor(delegate: JitRenderDelegate) {
super(delegate);
let snapShot = this.takeSnapshot();
assert.deepEqual(snapShot, [p, 'down', text, 'up', 'up']);
}
})(new JitRenderDelegate());
});
test('Can take nested snapshots of serialized blocks', (assert) => {
let div = doc.createElement('div');
let open = doc.createComment('<!--%+b:0%-->');
let text = doc.createTextNode('Foo');
let close = doc.createComment('<!--%-b:0%-->');
div.appendChild(open);
div.appendChild(text);
div.appendChild(close);
new (class extends RenderTest {
override element = div;
constructor(delegate: JitRenderDelegate) {
super(delegate);
let snapShot = this.takeSnapshot();
assert.deepEqual(snapShot, [open, text, close, 'up']);
}
})(new JitRenderDelegate());
});
});