Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Improve error messages of some assertions
Browse files Browse the repository at this point in the history
- to redirect
- to open successfully
- not to open authorized
- to open not found
  • Loading branch information
voidxnull committed Jun 6, 2017
1 parent df7157f commit 4394a5f
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions test-helpers/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ expect.addAssertion('to have body array length', function (expect, subject, valu

// TODO: Expect to yield a redirect to a specific path.
expect.addAssertion('to redirect', function (expect, subject/*, value*/) {
return expect(subjectToRequest(subject), 'to yield response', {
statusCode: 307
});
return expect(subjectToRequest(subject), 'to yield response', 307);
});

expect.addAssertion('to open successfully', function (expect, subject/*, value*/) {
return expect(subjectToRequest(subject), 'to yield response', {
statusCode: 200
});
return expect(subjectToRequest(subject), 'to yield response', 200);
});

expect.addAssertion('body to contain', function (expect, subject, value) {
Expand Down Expand Up @@ -121,21 +117,11 @@ expect.addAssertion('to open authorized', function (expect, subject/*, value*/)
});

expect.addAssertion('not to open authorized', function (expect, subject/*, value*/) {
expect.errorMode = 'bubble';
return expect(subjectToRequest(subject), 'to yield response', {})
.then(function (context) {
const status = context.httpResponse.statusLine.statusCode;
expect(status, 'to equal', 403);
});
return expect(subjectToRequest(subject), 'to yield response', 403);
});

expect.addAssertion('to open not found', function (expect, subject/*, value*/) {
return expect(subjectToRequest(subject), 'to yield response', {})
.then(function (context) {
const status = context.httpResponse.statusLine.statusCode;
expect(status, 'to equal', 404);
return context;
});
return expect(subjectToRequest(subject), 'to yield response', 404);
});

expect.addAssertion('to fail validation with', function (expect, subject, value) {
Expand Down

0 comments on commit 4394a5f

Please sign in to comment.