Skip to content

Commit

Permalink
bugfix: 486 Change method to use deepStrictEqual. (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelax committed Sep 6, 2018
1 parent c52338b commit 510a7ae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/test.js
Expand Up @@ -198,7 +198,7 @@ Test.prototype._assertBody = function(body, res) {
// parsed
if (typeof body === 'object' && !isregexp) {
try {
assert.deepEqual(body, res.body);
assert.deepStrictEqual(body, res.body);
} catch (err) {
a = util.inspect(body);
b = util.inspect(res.body);
Expand Down
31 changes: 31 additions & 0 deletions test/supertest.js
Expand Up @@ -496,6 +496,37 @@ describe('request(app)', function() {
});
});

it('should test response object types', function (done) {
var app = express();
app.get('/', function (req, res) {
res.status(200).json({ stringValue: 'foo', numberValue: 3 });
});

request(app)
.get('/')
.expect({ stringValue: 'foo', numberValue: 3 }, done);
});

it('should deep test response object types', function (done) {
var app = express();
app.get('/', function (req, res) {
res.status(200)
.json({ stringValue: 'foo', numberValue: 3, nestedObject: { innerString: '5' } });
});

request(app)
.get('/')
.expect({ stringValue: 'foo', numberValue: 3, nestedObject: { innerString: 5 } })
.end(function(err, res) {
err.message.should.equal('expected { stringValue: \'foo\',\n numberValue: 3,\n nestedObject: { innerString: 5 } } response body, got { stringValue: \'foo\',\n numberValue: 3,\n nestedObject: { innerString: \'5\' } }'); // eslint-disable-line max-len

request(app)
.get('/')
.expect({ stringValue: 'foo', numberValue: 3, nestedObject: { innerString: '5' } })
.end(done);
});
});

it('should support regular expressions', function(done) {
var app = express();

Expand Down

0 comments on commit 510a7ae

Please sign in to comment.