|
53 | 53 |
|
54 | 54 | it('String template', function () { |
55 | 55 | expect( |
56 | | - tmpl('{%=o.value%}', data), |
| 56 | + tmpl('{%=o.value%}', data) |
| 57 | + ).to.be( |
57 | 58 | 'value' |
58 | 59 | ); |
59 | 60 | }); |
60 | 61 |
|
61 | 62 | it('Load template by id', function () { |
62 | 63 | expect( |
63 | | - tmpl('template', data), |
| 64 | + tmpl('template', data) |
| 65 | + ).to.be( |
64 | 66 | 'value' |
65 | 67 | ); |
66 | 68 | }); |
67 | 69 |
|
68 | 70 | it('Retun function when called without data parameter', function () { |
69 | 71 | expect( |
70 | | - tmpl('{%=o.value%}')(data), |
| 72 | + tmpl('{%=o.value%}')(data) |
| 73 | + ).to.be( |
71 | 74 | 'value' |
72 | 75 | ); |
73 | 76 | }); |
|
85 | 88 |
|
86 | 89 | it('Escape HTML special characters with {%=o.prop%}', function () { |
87 | 90 | expect( |
88 | | - tmpl('{%=o.special%}', data), |
| 91 | + tmpl('{%=o.special%}', data) |
| 92 | + ).to.be( |
89 | 93 | '<>&"'' |
90 | 94 | ); |
91 | 95 | }); |
92 | 96 |
|
93 | 97 | it('Allow HTML special characters with {%#o.prop%}', function () { |
94 | 98 | expect( |
95 | | - tmpl('{%#o.special%}', data), |
| 99 | + tmpl('{%#o.special%}', data) |
| 100 | + ).to.be( |
96 | 101 | '<>&"\'\x00' |
97 | 102 | ); |
98 | 103 | }); |
99 | 104 |
|
100 | 105 | it('Function call', function () { |
101 | 106 | expect( |
102 | | - tmpl('{%=o.func()%}', data), |
| 107 | + tmpl('{%=o.func()%}', data) |
| 108 | + ).to.be( |
103 | 109 | 'value' |
104 | 110 | ); |
105 | 111 | }); |
106 | 112 |
|
107 | 113 | it('Dot notation', function () { |
108 | 114 | expect( |
109 | | - tmpl('{%=o.deep.value%}', data), |
| 115 | + tmpl('{%=o.deep.value%}', data) |
| 116 | + ).to.be( |
110 | 117 | 'value' |
111 | 118 | ); |
112 | 119 | }); |
113 | 120 |
|
114 | 121 | it('Handle single quotes', function () { |
115 | 122 | expect( |
116 | | - tmpl('\'single quotes\'{%=": \'"%}', data), |
117 | | - '\'single quotes\': \'' |
| 123 | + tmpl('\'single quotes\'{%=": \'"%}', data) |
| 124 | + ).to.be( |
| 125 | + '\'single quotes\': '' |
118 | 126 | ); |
119 | 127 | }); |
120 | 128 |
|
121 | 129 | it('Handle double quotes', function () { |
122 | 130 | expect( |
123 | | - tmpl('"double quotes"{%=": \\""%}', data), |
| 131 | + tmpl('"double quotes"{%=": \\""%}', data) |
| 132 | + ).to.be( |
124 | 133 | '"double quotes": "' |
125 | 134 | ); |
126 | 135 | }); |
127 | 136 |
|
128 | 137 | it('Handle backslashes', function () { |
129 | 138 | expect( |
130 | | - tmpl('\\backslashes\\{%=": \\\\"%}', data), |
| 139 | + tmpl('\\backslashes\\{%=": \\\\"%}', data) |
| 140 | + ).to.be( |
131 | 141 | '\\backslashes\\: \\' |
132 | 142 | ); |
133 | 143 | }); |
|
177 | 187 |
|
178 | 188 | it('Escape HTML special characters with print(data)', function () { |
179 | 189 | expect( |
180 | | - tmpl('{% print(o.special); %}', data), |
| 190 | + tmpl('{% print(o.special); %}', data) |
| 191 | + ).to.be( |
181 | 192 | '<>&"'' |
182 | 193 | ); |
183 | 194 | }); |
184 | 195 |
|
185 | 196 | it('Allow HTML special characters with print(data, true)', function () { |
186 | 197 | expect( |
187 | | - tmpl('{% print(o.special, true); %}', data), |
| 198 | + tmpl('{% print(o.special, true); %}', data) |
| 199 | + ).to.be( |
188 | 200 | '<>&"\'\x00' |
189 | 201 | ); |
190 | 202 | }); |
|
219 | 231 |
|
220 | 232 | it('Include template', function () { |
221 | 233 | expect( |
222 | | - tmpl('{% include("template", {value: "value"}); %}', data), |
| 234 | + tmpl('{% include("template", {value: "value"}); %}', data) |
| 235 | + ).to.be( |
223 | 236 | 'value' |
224 | 237 | ); |
225 | 238 | }); |
226 | 239 |
|
227 | 240 | it('If condition', function () { |
228 | 241 | expect( |
229 | | - tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data), |
| 242 | + tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data) |
| 243 | + ).to.be( |
230 | 244 | 'true' |
231 | 245 | ); |
232 | 246 | }); |
|
0 commit comments