Skip to content
This repository was archived by the owner on Jul 8, 2020. It is now read-only.

Commit 2a1e1bb

Browse files
committed
Extract status assertion into common fn
1 parent f7b24b2 commit 2a1e1bb

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Diff for: test/integration/specs/domains.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var expect = require('chai').expect;
44
var uuid = require('node-uuid');
5+
var utils = require('../utils')
56

67
module.exports = function (server) {
78

@@ -14,33 +15,30 @@ module.exports = function (server) {
1415

1516
it('can get a domain by id', function () {
1617
return server.injectThen('/domains/' + domain.id)
18+
.tap(utils.assertStatus(200))
1719
.then(function (response) {
18-
expect(response.statusCode).to.equal(200);
1920
expect(JSON.parse(response.payload)).to.have.property('name', 'ourgala.org');
2021
});
2122
});
2223

2324
it('can get a domain by name', function () {
2425
return server.injectThen('/domains/ourgala.org')
26+
.tap(utils.assertStatus(200))
2527
.then(function (response) {
26-
expect(response.statusCode).to.equal(200);
2728
expect(JSON.parse(response.payload)).to.have.property('id', domain.id);
2829
});
2930
});
3031

3132
it('can get the related campaign', function () {
3233
return server.injectThen('/domains/ourgala.org?expand[]=campaign')
34+
.tap(utils.assertStatus(200))
3335
.then(function (response) {
34-
expect(response.statusCode).to.equal(200);
3536
expect(JSON.parse(response.payload)).to.have.deep.property('campaign.id').with.length(36);
3637
});
3738
});
3839

3940
it('responds with 404 if the domain is not found', function () {
40-
return server.injectThen('/domains/theirgala.org')
41-
.then(function (response) {
42-
expect(response.statusCode).to.equal(404);
43-
});
41+
return server.injectThen('/domains/theirgala.org').then(utils.assertStatus(404));
4442
});
4543

4644
});

Diff for: test/integration/utils.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
var expect = require('chai').expect;
4+
5+
exports.assertStatus = function assertStatus (statusCode) {
6+
return function statusValidator (payload) {
7+
expect(payload.statusCode).to.equal(statusCode);
8+
}
9+
}

0 commit comments

Comments
 (0)