|
54 | 54 | it('String template', function () { |
55 | 55 | expect( |
56 | 56 | tmpl('{%=o.value%}', data) |
57 | | - ).to.eql( |
| 57 | + ).to.be( |
58 | 58 | 'value' |
59 | 59 | ); |
60 | 60 | }); |
61 | 61 |
|
62 | 62 | it('Load template by id', function () { |
63 | 63 | expect( |
64 | 64 | tmpl('template', data) |
65 | | - ).to.eql( |
| 65 | + ).to.be( |
66 | 66 | 'value' |
67 | 67 | ); |
68 | 68 | }); |
69 | 69 |
|
70 | 70 | it('Retun function when called without data parameter', function () { |
71 | 71 | expect( |
72 | 72 | tmpl('{%=o.value%}')(data) |
73 | | - ).to.eql( |
| 73 | + ).to.be( |
74 | 74 | 'value' |
75 | 75 | ); |
76 | 76 | }); |
|
89 | 89 | it('Escape HTML special characters with {%=o.prop%}', function () { |
90 | 90 | expect( |
91 | 91 | tmpl('{%=o.special%}', data) |
92 | | - ).to.eql( |
| 92 | + ).to.be( |
93 | 93 | '<>&"'' |
94 | 94 | ); |
95 | 95 | }); |
96 | 96 |
|
97 | 97 | it('Allow HTML special characters with {%#o.prop%}', function () { |
98 | 98 | expect( |
99 | 99 | tmpl('{%#o.special%}', data) |
100 | | - ).to.eql( |
| 100 | + ).to.be( |
101 | 101 | '<>&"\'\x00' |
102 | 102 | ); |
103 | 103 | }); |
104 | 104 |
|
105 | 105 | it('Function call', function () { |
106 | 106 | expect( |
107 | 107 | tmpl('{%=o.func()%}', data) |
108 | | - ).to.eql( |
| 108 | + ).to.be( |
109 | 109 | 'value' |
110 | 110 | ); |
111 | 111 | }); |
112 | 112 |
|
113 | 113 | it('Dot notation', function () { |
114 | 114 | expect( |
115 | 115 | tmpl('{%=o.deep.value%}', data) |
116 | | - ).to.eql( |
| 116 | + ).to.be( |
117 | 117 | 'value' |
118 | 118 | ); |
119 | 119 | }); |
120 | 120 |
|
121 | 121 | it('Handle single quotes', function () { |
122 | 122 | expect( |
123 | 123 | tmpl('\'single quotes\'{%=": \'"%}', data) |
124 | | - ).to.eql( |
| 124 | + ).to.be( |
125 | 125 | '\'single quotes\': '' |
126 | 126 | ); |
127 | 127 | }); |
128 | 128 |
|
129 | 129 | it('Handle double quotes', function () { |
130 | 130 | expect( |
131 | 131 | tmpl('"double quotes"{%=": \\""%}', data) |
132 | | - ).to.eql( |
| 132 | + ).to.be( |
133 | 133 | '"double quotes": "' |
134 | 134 | ); |
135 | 135 | }); |
136 | 136 |
|
137 | 137 | it('Handle backslashes', function () { |
138 | 138 | expect( |
139 | 139 | tmpl('\\backslashes\\{%=": \\\\"%}', data) |
140 | | - ).to.eql( |
| 140 | + ).to.be( |
141 | 141 | '\\backslashes\\: \\' |
142 | 142 | ); |
143 | 143 | }); |
|
151 | 151 | '{%=o.zeroValue%}', |
152 | 152 | data |
153 | 153 | ) |
154 | | - ).to.eql( |
| 154 | + ).to.be( |
155 | 155 | 'false0' |
156 | 156 | ); |
157 | 157 | }); |
|
165 | 165 | '{%#o.zeroValue%}', |
166 | 166 | data |
167 | 167 | ) |
168 | | - ).to.eql( |
| 168 | + ).to.be( |
169 | 169 | 'false0' |
170 | 170 | ); |
171 | 171 | }); |
|
176 | 176 | '\n\r\t{%=o.value%} \n\r\t{%=o.value%} ', |
177 | 177 | data |
178 | 178 | ) |
179 | | - ).to.eql( |
| 179 | + ).to.be( |
180 | 180 | '\n\r\tvalue \n\r\tvalue ' |
181 | 181 | ); |
182 | 182 | }); |
|
188 | 188 | it('Escape HTML special characters with print(data)', function () { |
189 | 189 | expect( |
190 | 190 | tmpl('{% print(o.special); %}', data) |
191 | | - ).to.eql( |
| 191 | + ).to.be( |
192 | 192 | '<>&"'' |
193 | 193 | ); |
194 | 194 | }); |
195 | 195 |
|
196 | 196 | it('Allow HTML special characters with print(data, true)', function () { |
197 | 197 | expect( |
198 | 198 | tmpl('{% print(o.special, true); %}', data) |
199 | | - ).to.eql( |
| 199 | + ).to.be( |
200 | 200 | '<>&"\'\x00' |
201 | 201 | ); |
202 | 202 | }); |
|
210 | 210 | '{% print(o.zeroValue); %}', |
211 | 211 | data |
212 | 212 | ) |
213 | | - ).to.eql( |
| 213 | + ).to.be( |
214 | 214 | 'false0' |
215 | 215 | ); |
216 | 216 | }); |
|
224 | 224 | '{% print(o.zeroValue, true); %}', |
225 | 225 | data |
226 | 226 | ) |
227 | | - ).to.eql( |
| 227 | + ).to.be( |
228 | 228 | 'false0' |
229 | 229 | ); |
230 | 230 | }); |
231 | 231 |
|
232 | 232 | it('Include template', function () { |
233 | 233 | expect( |
234 | 234 | tmpl('{% include("template", {value: "value"}); %}', data) |
235 | | - ).to.eql( |
| 235 | + ).to.be( |
236 | 236 | 'value' |
237 | 237 | ); |
238 | 238 | }); |
239 | 239 |
|
240 | 240 | it('If condition', function () { |
241 | 241 | expect( |
242 | 242 | tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data) |
243 | | - ).to.eql( |
| 243 | + ).to.be( |
244 | 244 | 'true' |
245 | 245 | ); |
246 | 246 | }); |
|
251 | 251 | '{% if (o.undefinedValue) { %}false{% } else { %}true{% } %}', |
252 | 252 | data |
253 | 253 | ) |
254 | | - ).to.eql( |
| 254 | + ).to.be( |
255 | 255 | 'true' |
256 | 256 | ); |
257 | 257 | }); |
|
263 | 263 | '{%=o.list[i]%}{% } %}', |
264 | 264 | data |
265 | 265 | ) |
266 | | - ).to.eql( |
| 266 | + ).to.be( |
267 | 267 | '12345' |
268 | 268 | ); |
269 | 269 | }); |
|
275 | 275 | 'print(o.list[i]);} %}', |
276 | 276 | data |
277 | 277 | ) |
278 | | - ).to.eql( |
| 278 | + ).to.be( |
279 | 279 | '12345' |
280 | 280 | ); |
281 | 281 | }); |
|
287 | 287 | 'include("template", {value: o.list[i]});} %}', |
288 | 288 | data |
289 | 289 | ).replace(/[\r\n]/g, '') |
290 | | - ).to.eql( |
| 290 | + ).to.be( |
291 | 291 | '12345' |
292 | 292 | ); |
293 | 293 | }); |
|
298 | 298 | '{% if (o.list.length % 5 === 0) { %}5 list items{% } %}', |
299 | 299 | data |
300 | 300 | ).replace(/[\r\n]/g, '') |
301 | | - ).to.eql( |
| 301 | + ).to.be( |
302 | 302 | '5 list items' |
303 | 303 | ); |
304 | 304 | }); |
|
0 commit comments