Skip to content

Commit bc5ca05

Browse files
committedFeb 22, 2022
tests: remove usage of should
·
v5.1.04.18.0
1 parent 9967ffb commit bc5ca05

File tree

6 files changed

+46
-47
lines changed

6 files changed

+46
-47
lines changed
 

‎package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
"nyc": "15.1.0",
7777
"pbkdf2-password": "1.2.1",
7878
"resolve-path": "1.4.0",
79-
"should": "13.2.3",
8079
"supertest": "6.2.2",
8180
"vhost": "~3.0.2"
8281
},

‎test/Route.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
var after = require('after');
4-
var should = require('should');
4+
var assert = require('assert')
55
var express = require('../')
66
, Route = express.Route
77
, methods = require('methods')
@@ -25,7 +25,7 @@ describe('Route', function(){
2525

2626
route.dispatch(req, {}, function (err) {
2727
if (err) return done(err);
28-
should(req.called).be.ok()
28+
assert.ok(req.called)
2929
done();
3030
});
3131
})
@@ -35,7 +35,7 @@ describe('Route', function(){
3535
var route = new Route('/foo');
3636
var cb = after(methods.length, function (err) {
3737
if (err) return done(err);
38-
count.should.equal(methods.length);
38+
assert.strictEqual(count, methods.length)
3939
done();
4040
});
4141

@@ -66,7 +66,7 @@ describe('Route', function(){
6666

6767
route.dispatch(req, {}, function (err) {
6868
if (err) return done(err);
69-
req.count.should.equal(2);
69+
assert.strictEqual(req.count, 2)
7070
done();
7171
});
7272
})
@@ -84,7 +84,7 @@ describe('Route', function(){
8484

8585
route.dispatch(req, {}, function (err) {
8686
if (err) return done(err);
87-
should(req.called).be.ok()
87+
assert.ok(req.called)
8888
done();
8989
});
9090
})
@@ -104,7 +104,7 @@ describe('Route', function(){
104104

105105
route.dispatch(req, {}, function (err) {
106106
if (err) return done(err);
107-
should(req.called).be.true()
107+
assert.ok(req.called)
108108
done();
109109
});
110110
})
@@ -130,7 +130,7 @@ describe('Route', function(){
130130

131131
route.dispatch(req, {}, function (err) {
132132
if (err) return done(err);
133-
req.order.should.equal('abc');
133+
assert.strictEqual(req.order, 'abc')
134134
done();
135135
});
136136
})
@@ -156,9 +156,9 @@ describe('Route', function(){
156156
});
157157

158158
route.dispatch(req, {}, function (err) {
159-
should(err).be.ok()
160-
should(err.message).equal('foobar');
161-
req.order.should.equal('a');
159+
assert.ok(err)
160+
assert.strictEqual(err.message, 'foobar')
161+
assert.strictEqual(req.order, 'a')
162162
done();
163163
});
164164
})
@@ -182,9 +182,9 @@ describe('Route', function(){
182182
});
183183

184184
route.dispatch(req, {}, function (err) {
185-
should(err).be.ok()
186-
should(err.message).equal('foobar');
187-
req.order.should.equal('a');
185+
assert.ok(err)
186+
assert.strictEqual(err.message, 'foobar')
187+
assert.strictEqual(req.order, 'a')
188188
done();
189189
});
190190
});
@@ -208,7 +208,7 @@ describe('Route', function(){
208208

209209
route.dispatch(req, {}, function (err) {
210210
if (err) return done(err);
211-
should(req.message).equal('oops');
211+
assert.strictEqual(req.message, 'oops')
212212
done();
213213
});
214214
});
@@ -222,8 +222,8 @@ describe('Route', function(){
222222
});
223223

224224
route.dispatch(req, {}, function(err){
225-
should(err).be.ok()
226-
err.message.should.equal('boom!');
225+
assert.ok(err)
226+
assert.strictEqual(err.message, 'boom!')
227227
done();
228228
});
229229
});
@@ -234,7 +234,7 @@ describe('Route', function(){
234234

235235
route.all(function(err, req, res, next){
236236
// this should not execute
237-
true.should.be.false()
237+
throw new Error('should not be called')
238238
});
239239

240240
route.dispatch(req, {}, done);

‎test/exports.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
var assert = require('assert')
44
var express = require('../');
55
var request = require('supertest');
6-
var should = require('should');
76

87
describe('exports', function(){
98
it('should expose Router', function(){
10-
express.Router.should.be.a.Function()
9+
assert.strictEqual(typeof express.Router, 'function')
1110
})
1211

1312
it('should expose json middleware', function () {
@@ -36,20 +35,23 @@ describe('exports', function(){
3635
})
3736

3837
it('should expose the application prototype', function(){
39-
express.application.set.should.be.a.Function()
38+
assert.strictEqual(typeof express.application, 'object')
39+
assert.strictEqual(typeof express.application.set, 'function')
4040
})
4141

4242
it('should expose the request prototype', function(){
43-
express.request.accepts.should.be.a.Function()
43+
assert.strictEqual(typeof express.request, 'object')
44+
assert.strictEqual(typeof express.request.accepts, 'function')
4445
})
4546

4647
it('should expose the response prototype', function(){
47-
express.response.send.should.be.a.Function()
48+
assert.strictEqual(typeof express.response, 'object')
49+
assert.strictEqual(typeof express.response.send, 'function')
4850
})
4951

5052
it('should permit modifying the .application prototype', function(){
5153
express.application.foo = function(){ return 'bar'; };
52-
express().foo().should.equal('bar');
54+
assert.strictEqual(express().foo(), 'bar')
5355
})
5456

5557
it('should permit modifying the .request prototype', function(done){
@@ -79,10 +81,7 @@ describe('exports', function(){
7981
})
8082

8183
it('should throw on old middlewares', function(){
82-
var error;
83-
try { express.bodyParser; } catch (e) { error = e; }
84-
should(error).have.property('message');
85-
error.message.should.containEql('middleware');
86-
error.message.should.containEql('bodyParser');
84+
assert.throws(function () { express.bodyParser() }, /Error:.*middleware.*bodyParser/)
85+
assert.throws(function () { express.limit() }, /Error:.*middleware.*limit/)
8786
})
8887
})

‎test/mocha.opts

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎test/res.sendFile.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var express = require('../')
77
, assert = require('assert');
88
var onFinished = require('on-finished');
99
var path = require('path');
10-
var should = require('should');
1110
var fixtures = path.join(__dirname, 'fixtures');
1211
var utils = require('./support/utils');
1312

@@ -359,15 +358,13 @@ describe('res', function(){
359358

360359
app.use(function (req, res) {
361360
res.sendFile(path.resolve(fixtures, 'does-not-exist'), function (err) {
362-
should(err).be.ok()
363-
err.status.should.equal(404);
364-
res.send('got it');
361+
res.send(err ? 'got ' + err.status + ' error' : 'no error')
365362
});
366363
});
367364

368365
request(app)
369-
.get('/')
370-
.expect(200, 'got it', done);
366+
.get('/')
367+
.expect(200, 'got 404 error', done)
371368
})
372369
})
373370

@@ -539,7 +536,7 @@ describe('res', function(){
539536
app.use(function(req, res){
540537
res.sendfile('test/fixtures/user.html', function(err){
541538
assert(!res.headersSent);
542-
req.socket.listeners('error').should.have.length(1); // node's original handler
539+
assert.strictEqual(req.socket.listeners('error').length, 1) // node's original handler
543540
done();
544541
});
545542

@@ -783,12 +780,12 @@ describe('res', function(){
783780
});
784781

785782
request(app)
786-
.get('/')
787-
.end(function(err, res){
788-
res.statusCode.should.equal(404);
789-
calls.should.equal(1);
790-
done();
791-
});
783+
.get('/')
784+
.expect(404, function (err) {
785+
if (err) return done(err)
786+
assert.strictEqual(calls, 1)
787+
done()
788+
})
792789
})
793790

794791
describe('with non-GET', function(){

‎test/utils.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
var assert = require('assert');
44
var Buffer = require('safe-buffer').Buffer
5-
var should = require('should')
65
var utils = require('../lib/utils');
76

87
describe('utils.etag(body, encoding)', function(){
@@ -91,7 +90,14 @@ describe('utils.isAbsolute()', function(){
9190
describe('utils.flatten(arr)', function(){
9291
it('should flatten an array', function(){
9392
var arr = ['one', ['two', ['three', 'four'], 'five']];
94-
should(utils.flatten(arr))
95-
.eql(['one', 'two', 'three', 'four', 'five'])
93+
var flat = utils.flatten(arr)
94+
95+
assert.strictEqual(flat.length, 5)
96+
assert.strictEqual(flat[0], 'one')
97+
assert.strictEqual(flat[1], 'two')
98+
assert.strictEqual(flat[2], 'three')
99+
assert.strictEqual(flat[3], 'four')
100+
assert.strictEqual(flat[4], 'five')
101+
assert.ok(flat.every(function (v) { return typeof v === 'string' }))
96102
})
97103
})

0 commit comments

Comments
 (0)
Please sign in to comment.