Skip to content

Commit bd4fdfe

Browse files
committed
tests: remove global dependency on should
fixes #4797
1 parent 215f484 commit bd4fdfe

14 files changed

+142
-165
lines changed

test/app.engine.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
var assert = require('assert')
23
var express = require('../')
34
, fs = require('fs');
45
var path = require('path')
@@ -22,16 +23,16 @@ describe('app', function(){
2223

2324
app.render('user.html', function(err, str){
2425
if (err) return done(err);
25-
str.should.equal('<p>tobi</p>');
26+
assert.strictEqual(str, '<p>tobi</p>')
2627
done();
2728
})
2829
})
2930

3031
it('should throw when the callback is missing', function(){
3132
var app = express();
32-
(function(){
33+
assert.throws(function () {
3334
app.engine('.html', null);
34-
}).should.throw('callback function required');
35+
}, /callback function required/)
3536
})
3637

3738
it('should work without leading "."', function(done){
@@ -43,7 +44,7 @@ describe('app', function(){
4344

4445
app.render('user.html', function(err, str){
4546
if (err) return done(err);
46-
str.should.equal('<p>tobi</p>');
47+
assert.strictEqual(str, '<p>tobi</p>')
4748
done();
4849
})
4950
})
@@ -58,7 +59,7 @@ describe('app', function(){
5859

5960
app.render('user', function(err, str){
6061
if (err) return done(err);
61-
str.should.equal('<p>tobi</p>');
62+
assert.strictEqual(str, '<p>tobi</p>')
6263
done();
6364
})
6465
})
@@ -73,7 +74,7 @@ describe('app', function(){
7374

7475
app.render('user', function(err, str){
7576
if (err) return done(err);
76-
str.should.equal('<p>tobi</p>');
77+
assert.strictEqual(str, '<p>tobi</p>')
7778
done();
7879
})
7980
})

test/app.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ describe('app.parent', function(){
3232
blog.use('/admin', blogAdmin);
3333

3434
assert(!app.parent, 'app.parent');
35-
blog.parent.should.equal(app);
36-
blogAdmin.parent.should.equal(blog);
35+
assert.strictEqual(blog.parent, app)
36+
assert.strictEqual(blogAdmin.parent, blog)
3737
})
3838
})
3939

@@ -48,10 +48,10 @@ describe('app.mountpath', function(){
4848
app.use(fallback);
4949
blog.use('/admin', admin);
5050

51-
admin.mountpath.should.equal('/admin');
52-
app.mountpath.should.equal('/');
53-
blog.mountpath.should.equal('/blog');
54-
fallback.mountpath.should.equal('/');
51+
assert.strictEqual(admin.mountpath, '/admin')
52+
assert.strictEqual(app.mountpath, '/')
53+
assert.strictEqual(blog.mountpath, '/blog')
54+
assert.strictEqual(fallback.mountpath, '/')
5555
})
5656
})
5757

@@ -76,17 +76,17 @@ describe('app.path()', function(){
7676
app.use('/blog', blog);
7777
blog.use('/admin', blogAdmin);
7878

79-
app.path().should.equal('');
80-
blog.path().should.equal('/blog');
81-
blogAdmin.path().should.equal('/blog/admin');
79+
assert.strictEqual(app.path(), '')
80+
assert.strictEqual(blog.path(), '/blog')
81+
assert.strictEqual(blogAdmin.path(), '/blog/admin')
8282
})
8383
})
8484

8585
describe('in development', function(){
8686
it('should disable "view cache"', function(){
8787
process.env.NODE_ENV = 'development';
8888
var app = express();
89-
app.enabled('view cache').should.be.false()
89+
assert.ok(!app.enabled('view cache'))
9090
process.env.NODE_ENV = 'test';
9191
})
9292
})
@@ -95,7 +95,7 @@ describe('in production', function(){
9595
it('should enable "view cache"', function(){
9696
process.env.NODE_ENV = 'production';
9797
var app = express();
98-
app.enabled('view cache').should.be.true()
98+
assert.ok(app.enabled('view cache'))
9999
process.env.NODE_ENV = 'test';
100100
})
101101
})
@@ -104,7 +104,7 @@ describe('without NODE_ENV', function(){
104104
it('should default to development', function(){
105105
process.env.NODE_ENV = '';
106106
var app = express();
107-
app.get('env').should.equal('development');
107+
assert.strictEqual(app.get('env'), 'development')
108108
process.env.NODE_ENV = 'test';
109109
})
110110
})

test/app.locals.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11

2+
var assert = require('assert')
23
var express = require('../')
4+
var should = require('should')
35

46
describe('app', function(){
57
describe('.locals(obj)', function(){
68
it('should merge locals', function(){
79
var app = express();
8-
Object.keys(app.locals).should.eql(['settings']);
10+
should(Object.keys(app.locals)).eql(['settings'])
911
app.locals.user = 'tobi';
1012
app.locals.age = 2;
11-
Object.keys(app.locals).should.eql(['settings', 'user', 'age']);
12-
app.locals.user.should.equal('tobi');
13-
app.locals.age.should.equal(2);
13+
should(Object.keys(app.locals)).eql(['settings', 'user', 'age'])
14+
assert.strictEqual(app.locals.user, 'tobi')
15+
assert.strictEqual(app.locals.age, 2)
1416
})
1517
})
1618

@@ -19,8 +21,8 @@ describe('app', function(){
1921
var app = express();
2022
app.set('title', 'House of Manny');
2123
var obj = app.locals.settings;
22-
obj.should.have.property('env', 'test');
23-
obj.should.have.property('title', 'House of Manny');
24+
should(obj).have.property('env', 'test')
25+
should(obj).have.property('title', 'House of Manny')
2426
})
2527
})
2628
})

test/app.param.js

+14-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
var assert = require('assert')
23
var express = require('../')
34
, request = require('supertest');
45

@@ -40,7 +41,7 @@ describe('app', function(){
4041

4142
it('should fail if not given fn', function(){
4243
var app = express();
43-
app.param.bind(app, ':name', 'bob').should.throw();
44+
assert.throws(app.param.bind(app, ':name', 'bob'))
4445
})
4546
})
4647

@@ -57,24 +58,22 @@ describe('app', function(){
5758

5859
app.get('/post/:id', function(req, res){
5960
var id = req.params.id;
60-
id.should.be.a.Number()
61-
res.send('' + id);
61+
res.send((typeof id) + ':' + id)
6262
});
6363

6464
app.get('/user/:uid', function(req, res){
6565
var id = req.params.id;
66-
id.should.be.a.Number()
67-
res.send('' + id);
66+
res.send((typeof id) + ':' + id)
6867
});
6968

7069
request(app)
71-
.get('/user/123')
72-
.expect(200, '123', function (err) {
73-
if (err) return done(err)
74-
request(app)
75-
.get('/post/123')
76-
.expect('123', done);
77-
})
70+
.get('/user/123')
71+
.expect(200, 'number:123', function (err) {
72+
if (err) return done(err)
73+
request(app)
74+
.get('/post/123')
75+
.expect('number:123', done)
76+
})
7877
})
7978
})
8079

@@ -91,13 +90,12 @@ describe('app', function(){
9190

9291
app.get('/user/:id', function(req, res){
9392
var id = req.params.id;
94-
id.should.be.a.Number()
95-
res.send('' + id);
93+
res.send((typeof id) + ':' + id)
9694
});
9795

9896
request(app)
99-
.get('/user/123')
100-
.expect('123', done);
97+
.get('/user/123')
98+
.expect(200, 'number:123', done)
10199
})
102100

103101
it('should only call once per request', function(done) {

test/app.render.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('app', function(){
1313

1414
app.render(path.join(__dirname, 'fixtures', 'user.tmpl'), function (err, str) {
1515
if (err) return done(err);
16-
str.should.equal('<p>tobi</p>');
16+
assert.strictEqual(str, '<p>tobi</p>')
1717
done();
1818
})
1919
})
@@ -26,7 +26,7 @@ describe('app', function(){
2626

2727
app.render(path.join(__dirname, 'fixtures', 'user'), function (err, str) {
2828
if (err) return done(err);
29-
str.should.equal('<p>tobi</p>');
29+
assert.strictEqual(str, '<p>tobi</p>')
3030
done();
3131
})
3232
})
@@ -39,7 +39,7 @@ describe('app', function(){
3939

4040
app.render('user.tmpl', function (err, str) {
4141
if (err) return done(err);
42-
str.should.equal('<p>tobi</p>');
42+
assert.strictEqual(str, '<p>tobi</p>')
4343
done();
4444
})
4545
})
@@ -52,7 +52,7 @@ describe('app', function(){
5252

5353
app.render('blog/post', function (err, str) {
5454
if (err) return done(err);
55-
str.should.equal('<h1>blog post</h1>');
55+
assert.strictEqual(str, '<h1>blog post</h1>')
5656
done();
5757
})
5858
})
@@ -72,8 +72,8 @@ describe('app', function(){
7272
app.set('view', View);
7373

7474
app.render('something', function(err, str){
75-
err.should.be.ok()
76-
err.message.should.equal('err!');
75+
assert.ok(err)
76+
assert.strictEqual(err.message, 'err!')
7777
done();
7878
})
7979
})
@@ -113,7 +113,7 @@ describe('app', function(){
113113

114114
app.render('email.tmpl', function (err, str) {
115115
if (err) return done(err);
116-
str.should.equal('<p>This is an email</p>');
116+
assert.strictEqual(str, '<p>This is an email</p>')
117117
done();
118118
})
119119
})
@@ -128,7 +128,7 @@ describe('app', function(){
128128

129129
app.render('email', function(err, str){
130130
if (err) return done(err);
131-
str.should.equal('<p>This is an email</p>');
131+
assert.strictEqual(str, '<p>This is an email</p>')
132132
done();
133133
})
134134
})
@@ -143,7 +143,7 @@ describe('app', function(){
143143

144144
app.render('user.tmpl', function (err, str) {
145145
if (err) return done(err);
146-
str.should.equal('<p>tobi</p>');
146+
assert.strictEqual(str, '<p>tobi</p>')
147147
done();
148148
})
149149
})
@@ -161,7 +161,7 @@ describe('app', function(){
161161

162162
app.render('user.tmpl', function (err, str) {
163163
if (err) return done(err);
164-
str.should.equal('<span>tobi</span>');
164+
assert.strictEqual(str, '<span>tobi</span>')
165165
done();
166166
})
167167
})
@@ -178,7 +178,7 @@ describe('app', function(){
178178

179179
app.render('name.tmpl', function (err, str) {
180180
if (err) return done(err);
181-
str.should.equal('<p>tobi</p>');
181+
assert.strictEqual(str, '<p>tobi</p>')
182182
done();
183183
})
184184
})
@@ -219,7 +219,7 @@ describe('app', function(){
219219

220220
app.render('something', function(err, str){
221221
if (err) return done(err);
222-
str.should.equal('abstract engine');
222+
assert.strictEqual(str, 'abstract engine')
223223
done();
224224
})
225225
})
@@ -245,12 +245,12 @@ describe('app', function(){
245245

246246
app.render('something', function(err, str){
247247
if (err) return done(err);
248-
count.should.equal(1);
249-
str.should.equal('abstract engine');
248+
assert.strictEqual(count, 1)
249+
assert.strictEqual(str, 'abstract engine')
250250
app.render('something', function(err, str){
251251
if (err) return done(err);
252-
count.should.equal(2);
253-
str.should.equal('abstract engine');
252+
assert.strictEqual(count, 2)
253+
assert.strictEqual(str, 'abstract engine')
254254
done();
255255
})
256256
})
@@ -275,12 +275,12 @@ describe('app', function(){
275275

276276
app.render('something', function(err, str){
277277
if (err) return done(err);
278-
count.should.equal(1);
279-
str.should.equal('abstract engine');
278+
assert.strictEqual(count, 1)
279+
assert.strictEqual(str, 'abstract engine')
280280
app.render('something', function(err, str){
281281
if (err) return done(err);
282-
count.should.equal(1);
283-
str.should.equal('abstract engine');
282+
assert.strictEqual(count, 1)
283+
assert.strictEqual(str, 'abstract engine')
284284
done();
285285
})
286286
})
@@ -298,7 +298,7 @@ describe('app', function(){
298298

299299
app.render('user.tmpl', { user: user }, function (err, str) {
300300
if (err) return done(err);
301-
str.should.equal('<p>tobi</p>');
301+
assert.strictEqual(str, '<p>tobi</p>')
302302
done();
303303
})
304304
})
@@ -311,7 +311,7 @@ describe('app', function(){
311311

312312
app.render('user.tmpl', {}, function (err, str) {
313313
if (err) return done(err);
314-
str.should.equal('<p>tobi</p>');
314+
assert.strictEqual(str, '<p>tobi</p>')
315315
done();
316316
})
317317
})
@@ -325,7 +325,7 @@ describe('app', function(){
325325

326326
app.render('user.tmpl', { user: jane }, function (err, str) {
327327
if (err) return done(err);
328-
str.should.equal('<p>jane</p>');
328+
assert.strictEqual(str, '<p>jane</p>')
329329
done();
330330
})
331331
})
@@ -350,12 +350,12 @@ describe('app', function(){
350350

351351
app.render('something', {cache: true}, function(err, str){
352352
if (err) return done(err);
353-
count.should.equal(1);
354-
str.should.equal('abstract engine');
353+
assert.strictEqual(count, 1)
354+
assert.strictEqual(str, 'abstract engine')
355355
app.render('something', {cache: true}, function(err, str){
356356
if (err) return done(err);
357-
count.should.equal(1);
358-
str.should.equal('abstract engine');
357+
assert.strictEqual(count, 1)
358+
assert.strictEqual(str, 'abstract engine')
359359
done();
360360
})
361361
})

0 commit comments

Comments
 (0)