Skip to content

Commit aa33f95

Browse files
committed
Merge pull request blueimp#40 from steelywing/patch-1
fix test
2 parents eb5faac + 5798679 commit aa33f95

File tree

1 file changed

+39
-25
lines changed

1 file changed

+39
-25
lines changed

test/test.js

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,24 @@
5353

5454
it('String template', function () {
5555
expect(
56-
tmpl('{%=o.value%}', data),
56+
tmpl('{%=o.value%}', data)
57+
).to.eql(
5758
'value'
5859
);
5960
});
6061

6162
it('Load template by id', function () {
6263
expect(
63-
tmpl('template', data),
64+
tmpl('template', data)
65+
).to.eql(
6466
'value'
6567
);
6668
});
6769

6870
it('Retun function when called without data parameter', function () {
6971
expect(
70-
tmpl('{%=o.value%}')(data),
72+
tmpl('{%=o.value%}')(data)
73+
).to.eql(
7174
'value'
7275
);
7376
});
@@ -85,49 +88,56 @@
8588

8689
it('Escape HTML special characters with {%=o.prop%}', function () {
8790
expect(
88-
tmpl('{%=o.special%}', data),
91+
tmpl('{%=o.special%}', data)
92+
).to.eql(
8993
'<>&"''
9094
);
9195
});
9296

9397
it('Allow HTML special characters with {%#o.prop%}', function () {
9498
expect(
95-
tmpl('{%#o.special%}', data),
99+
tmpl('{%#o.special%}', data)
100+
).to.eql(
96101
'<>&"\'\x00'
97102
);
98103
});
99104

100105
it('Function call', function () {
101106
expect(
102-
tmpl('{%=o.func()%}', data),
107+
tmpl('{%=o.func()%}', data)
108+
).to.eql(
103109
'value'
104110
);
105111
});
106112

107113
it('Dot notation', function () {
108114
expect(
109-
tmpl('{%=o.deep.value%}', data),
115+
tmpl('{%=o.deep.value%}', data)
116+
).to.eql(
110117
'value'
111118
);
112119
});
113120

114121
it('Handle single quotes', function () {
115122
expect(
116-
tmpl('\'single quotes\'{%=": \'"%}', data),
117-
'\'single quotes\': \''
123+
tmpl('\'single quotes\'{%=": \'"%}', data)
124+
).to.eql(
125+
'\'single quotes\': &#39;'
118126
);
119127
});
120128

121129
it('Handle double quotes', function () {
122130
expect(
123-
tmpl('"double quotes"{%=": \\""%}', data),
131+
tmpl('"double quotes"{%=": \\""%}', data)
132+
).to.eql(
124133
'"double quotes": &quot;'
125134
);
126135
});
127136

128137
it('Handle backslashes', function () {
129138
expect(
130-
tmpl('\\backslashes\\{%=": \\\\"%}', data),
139+
tmpl('\\backslashes\\{%=": \\\\"%}', data)
140+
).to.eql(
131141
'\\backslashes\\: \\'
132142
);
133143
});
@@ -141,7 +151,7 @@
141151
'{%=o.zeroValue%}',
142152
data
143153
)
144-
).to.be(
154+
).to.eql(
145155
'false0'
146156
);
147157
});
@@ -155,7 +165,7 @@
155165
'{%#o.zeroValue%}',
156166
data
157167
)
158-
).to.be(
168+
).to.eql(
159169
'false0'
160170
);
161171
});
@@ -166,7 +176,7 @@
166176
'\n\r\t{%=o.value%} \n\r\t{%=o.value%} ',
167177
data
168178
)
169-
).to.be(
179+
).to.eql(
170180
'\n\r\tvalue \n\r\tvalue '
171181
);
172182
});
@@ -177,14 +187,16 @@
177187

178188
it('Escape HTML special characters with print(data)', function () {
179189
expect(
180-
tmpl('{% print(o.special); %}', data),
190+
tmpl('{% print(o.special); %}', data)
191+
).to.eql(
181192
'&lt;&gt;&amp;&quot;&#39;'
182193
);
183194
});
184195

185196
it('Allow HTML special characters with print(data, true)', function () {
186197
expect(
187-
tmpl('{% print(o.special, true); %}', data),
198+
tmpl('{% print(o.special, true); %}', data)
199+
).to.eql(
188200
'<>&"\'\x00'
189201
);
190202
});
@@ -198,7 +210,7 @@
198210
'{% print(o.zeroValue); %}',
199211
data
200212
)
201-
).to.be(
213+
).to.eql(
202214
'false0'
203215
);
204216
});
@@ -212,21 +224,23 @@
212224
'{% print(o.zeroValue, true); %}',
213225
data
214226
)
215-
).to.be(
227+
).to.eql(
216228
'false0'
217229
);
218230
});
219231

220232
it('Include template', function () {
221233
expect(
222-
tmpl('{% include("template", {value: "value"}); %}', data),
234+
tmpl('{% include("template", {value: "value"}); %}', data)
235+
).to.eql(
223236
'value'
224237
);
225238
});
226239

227240
it('If condition', function () {
228241
expect(
229-
tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data),
242+
tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data)
243+
).to.eql(
230244
'true'
231245
);
232246
});
@@ -237,7 +251,7 @@
237251
'{% if (o.undefinedValue) { %}false{% } else { %}true{% } %}',
238252
data
239253
)
240-
).to.be(
254+
).to.eql(
241255
'true'
242256
);
243257
});
@@ -249,7 +263,7 @@
249263
'{%=o.list[i]%}{% } %}',
250264
data
251265
)
252-
).to.be(
266+
).to.eql(
253267
'12345'
254268
);
255269
});
@@ -261,7 +275,7 @@
261275
'print(o.list[i]);} %}',
262276
data
263277
)
264-
).to.be(
278+
).to.eql(
265279
'12345'
266280
);
267281
});
@@ -273,7 +287,7 @@
273287
'include("template", {value: o.list[i]});} %}',
274288
data
275289
).replace(/[\r\n]/g, '')
276-
).to.be(
290+
).to.eql(
277291
'12345'
278292
);
279293
});
@@ -284,7 +298,7 @@
284298
'{% if (o.list.length % 5 === 0) { %}5 list items{% } %}',
285299
data
286300
).replace(/[\r\n]/g, '')
287-
).to.be(
301+
).to.eql(
288302
'5 list items'
289303
);
290304
});

0 commit comments

Comments
 (0)