Skip to content

Commit 70f71bf

Browse files
committed
Replace expect.js with chai.js.
Update mocha, standard and uglify-js.
1 parent 9dc4147 commit 70f71bf

File tree

11 files changed

+13964
-6036
lines changed

11 files changed

+13964
-6036
lines changed

js/compile.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
* http://www.opensource.org/licenses/MIT
1111
*/
1212

13-
/*global require, __dirname, process, console */
14-
1513
;(function () {
1614
'use strict'
1715
var path = require('path')

js/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* http://www.opensource.org/licenses/MIT
1010
*/
1111

12-
/* global document, tmpl */
12+
/* global tmpl */
1313

1414
;(function () {
1515
'use strict'

js/runtime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* http://www.opensource.org/licenses/MIT
1010
*/
1111

12-
/*global define, module */
12+
/* global define */
1313

1414
;(function ($) {
1515
'use strict'
@@ -20,7 +20,7 @@
2020
}
2121
}
2222
tmpl.cache = {}
23-
tmpl.encReg = /[<>&"'\x00]/g
23+
tmpl.encReg = /[<>&"'\x00]/g // eslint-disable-line no-control-regex
2424
tmpl.encMap = {
2525
'<': '&lt;',
2626
'>': '&gt;',

js/tmpl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* http://ejohn.org/blog/javascript-micro-templating/
1313
*/
1414

15-
/*global document, define, module */
15+
/* global define */
1616

1717
;(function ($) {
1818
'use strict'
@@ -55,7 +55,7 @@
5555
return "_s+='"
5656
}
5757
}
58-
tmpl.encReg = /[<>&"'\x00]/g
58+
tmpl.encReg = /[<>&"'\x00]/g // eslint-disable-line no-control-regex
5959
tmpl.encMap = {
6060
'<': '&lt;',
6161
'>': '&gt;',

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
},
2020
"license": "MIT",
2121
"devDependencies": {
22-
"expect.js": "0.3.1",
23-
"mocha": "2.3.4",
24-
"standard": "6.0.7",
25-
"uglify-js": "2.6.1"
22+
"chai": "3.5.0",
23+
"mocha": "3.1.0",
24+
"standard": "8.3.0",
25+
"uglify-js": "2.7.3"
2626
},
2727
"scripts": {
28-
"test": "standard js/*.js test/*.js && mocha",
28+
"lint": "standard js/*.js test/*.js",
29+
"unit": "mocha",
30+
"test": "npm run lint && npm run unit",
2931
"build": "cd js && uglifyjs tmpl.js -c -m -o tmpl.min.js --source-map tmpl.min.js.map",
3032
"preversion": "npm test",
3133
"version": "npm run build && git add -A js",

test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<body>
2525
<div id="mocha"></div>
2626
<script src="vendor/mocha.js"></script>
27-
<script src="vendor/expect.js"></script>
27+
<script src="vendor/chai.js"></script>
2828
<script>
2929
mocha.setup('bdd');
3030
</script>

test/test.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* http://www.opensource.org/licenses/MIT
1010
*/
1111

12-
/*global beforeEach, afterEach, describe, it, require */
12+
/* global beforeEach, afterEach, describe, it */
1313

1414
;(function (context, expect, tmpl) {
1515
'use strict'
@@ -53,23 +53,23 @@
5353
it('String template', function () {
5454
expect(
5555
tmpl('{%=o.value%}', data)
56-
).to.be(
56+
).to.equal(
5757
'value'
5858
)
5959
})
6060

6161
it('Load template by id', function () {
6262
expect(
6363
tmpl('template', data)
64-
).to.be(
64+
).to.equal(
6565
'value'
6666
)
6767
})
6868

6969
it('Retun function when called without data parameter', function () {
7070
expect(
7171
tmpl('{%=o.value%}')(data)
72-
).to.be(
72+
).to.equal(
7373
'value'
7474
)
7575
})
@@ -86,55 +86,55 @@
8686
it('Escape HTML special characters with {%=o.prop%}', function () {
8787
expect(
8888
tmpl('{%=o.special%}', data)
89-
).to.be(
89+
).to.equal(
9090
'&lt;&gt;&amp;&quot;&#39;'
9191
)
9292
})
9393

9494
it('Allow HTML special characters with {%#o.prop%}', function () {
9595
expect(
9696
tmpl('{%#o.special%}', data)
97-
).to.be(
97+
).to.equal(
9898
'<>&"\'\x00'
9999
)
100100
})
101101

102102
it('Function call', function () {
103103
expect(
104104
tmpl('{%=o.func()%}', data)
105-
).to.be(
105+
).to.equal(
106106
'value'
107107
)
108108
})
109109

110110
it('Dot notation', function () {
111111
expect(
112112
tmpl('{%=o.deep.value%}', data)
113-
).to.be(
113+
).to.equal(
114114
'value'
115115
)
116116
})
117117

118118
it('Handle single quotes', function () {
119119
expect(
120120
tmpl('\'single quotes\'{%=": \'"%}', data)
121-
).to.be(
121+
).to.equal(
122122
"'single quotes': &#39;"
123123
)
124124
})
125125

126126
it('Handle double quotes', function () {
127127
expect(
128128
tmpl('"double quotes"{%=": \\""%}', data)
129-
).to.be(
129+
).to.equal(
130130
'"double quotes": &quot;'
131131
)
132132
})
133133

134134
it('Handle backslashes', function () {
135135
expect(
136136
tmpl('\\backslashes\\{%=": \\\\"%}', data)
137-
).to.be(
137+
).to.equal(
138138
'\\backslashes\\: \\'
139139
)
140140
})
@@ -148,7 +148,7 @@
148148
'{%=o.zeroValue%}',
149149
data
150150
)
151-
).to.be(
151+
).to.equal(
152152
'false0'
153153
)
154154
})
@@ -162,7 +162,7 @@
162162
'{%#o.zeroValue%}',
163163
data
164164
)
165-
).to.be(
165+
).to.equal(
166166
'false0'
167167
)
168168
})
@@ -173,7 +173,7 @@
173173
'\n\r\t{%=o.value%} \n\r\t{%=o.value%} ',
174174
data
175175
)
176-
).to.be(
176+
).to.equal(
177177
'\n\r\tvalue \n\r\tvalue '
178178
)
179179
})
@@ -183,15 +183,15 @@
183183
it('Escape HTML special characters with print(data)', function () {
184184
expect(
185185
tmpl('{% print(o.special); %}', data)
186-
).to.be(
186+
).to.equal(
187187
'&lt;&gt;&amp;&quot;&#39;'
188188
)
189189
})
190190

191191
it('Allow HTML special characters with print(data, true)', function () {
192192
expect(
193193
tmpl('{% print(o.special, true); %}', data)
194-
).to.be(
194+
).to.equal(
195195
'<>&"\'\x00'
196196
)
197197
})
@@ -205,7 +205,7 @@
205205
'{% print(o.zeroValue); %}',
206206
data
207207
)
208-
).to.be(
208+
).to.equal(
209209
'false0'
210210
)
211211
})
@@ -219,23 +219,23 @@
219219
'{% print(o.zeroValue, true); %}',
220220
data
221221
)
222-
).to.be(
222+
).to.equal(
223223
'false0'
224224
)
225225
})
226226

227227
it('Include template', function () {
228228
expect(
229229
tmpl('{% include("template", {value: "value"}); %}', data)
230-
).to.be(
230+
).to.equal(
231231
'value'
232232
)
233233
})
234234

235235
it('If condition', function () {
236236
expect(
237237
tmpl('{% if (o.value) { %}true{% } else { %}false{% } %}', data)
238-
).to.be(
238+
).to.equal(
239239
'true'
240240
)
241241
})
@@ -246,7 +246,7 @@
246246
'{% if (o.undefinedValue) { %}false{% } else { %}true{% } %}',
247247
data
248248
)
249-
).to.be(
249+
).to.equal(
250250
'true'
251251
)
252252
})
@@ -258,7 +258,7 @@
258258
'{%=o.list[i]%}{% } %}',
259259
data
260260
)
261-
).to.be(
261+
).to.equal(
262262
'12345'
263263
)
264264
})
@@ -270,7 +270,7 @@
270270
'print(o.list[i]);} %}',
271271
data
272272
)
273-
).to.be(
273+
).to.equal(
274274
'12345'
275275
)
276276
})
@@ -282,7 +282,7 @@
282282
'include("template", {value: o.list[i]});} %}',
283283
data
284284
).replace(/[\r\n]/g, '')
285-
).to.be(
285+
).to.equal(
286286
'12345'
287287
)
288288
})
@@ -293,13 +293,13 @@
293293
'{% if (o.list.length % 5 === 0) { %}5 list items{% } %}',
294294
data
295295
).replace(/[\r\n]/g, '')
296-
).to.be(
296+
).to.equal(
297297
'5 list items'
298298
)
299299
})
300300
})
301301
}(
302302
this,
303-
this.expect || require('expect.js'),
303+
(this.chai || require('chai')).expect,
304304
this.tmpl || require('../js/tmpl')
305305
))

0 commit comments

Comments
 (0)