/
concat-test.js
96 lines (64 loc) · 2.26 KB
/
concat-test.js
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
import { RenderingTest, moduleFor } from '../../utils/test-case';
import { set } from 'ember-metal/property_set';
moduleFor('Helpers test: {{concat}}', class extends RenderingTest {
['@test it concats static arguments']() {
this.render(`{{concat "foo" " " "bar" " " "baz"}}`);
this.assertText('foo bar baz');
}
['@test it updates for bound arguments']() {
this.render(`{{concat first second}}`, {
first: 'one',
second: 'two'
});
this.assertText('onetwo');
this.runTask(() => this.rerender());
this.assertText('onetwo');
this.runTask(() => set(this.context, 'first', 'three'));
this.assertText('threetwo');
this.runTask(() => set(this.context, 'second', 'four'));
this.assertText('threefour');
this.runTask(() => {
set(this.context, 'first', 'one');
set(this.context, 'second', 'two');
});
this.assertText('onetwo');
}
['@test it can be used as a sub-expression']() {
this.render(`{{concat (concat first second) (concat third fourth)}}`, {
first: 'one',
second: 'two',
third: 'three',
fourth: 'four'
});
this.assertText('onetwothreefour');
this.runTask(() => this.rerender());
this.assertText('onetwothreefour');
this.runTask(() => set(this.context, 'first', 'five'));
this.assertText('fivetwothreefour');
this.runTask(() => {
set(this.context, 'second', 'six');
set(this.context, 'third', 'seven');
});
this.assertText('fivesixsevenfour');
this.runTask(() => {
set(this.context, 'first', 'one');
set(this.context, 'second', 'two');
set(this.context, 'third', 'three');
});
this.assertText('onetwothreefour');
}
['@test it can be used as input for other helpers']() {
this.registerHelper('x-eq', ([ actual, expected]) => actual === expected);
this.render(`{{#if (x-eq (concat first second) "onetwo")}}Truthy!{{else}}False{{/if}}`, {
first: 'one',
second: 'two'
});
this.assertText('Truthy!');
this.runTask(() => this.rerender());
this.assertText('Truthy!');
this.runTask(() => set(this.context, 'first', 'three'));
this.assertText('False');
this.runTask(() => set(this.context, 'first', 'one'));
this.assertText('Truthy!');
}
});