Skip to content

Commit

Permalink
Improve coverage of 'to have items satisfying' and 'to have keys sati…
Browse files Browse the repository at this point in the history
…sfying', removed dead code.
  • Loading branch information
papandreou committed Apr 14, 2015
1 parent d30aba8 commit 533ec97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
14 changes: 2 additions & 12 deletions lib/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,7 @@ module.exports = function (expect) {
} else {
seenFirstRejected = true;
}
output.i().text(key).text(': ');
if (error._isUnexpected) {
output.block(error.output);
} else {
output.block(output.clone().text(error.message));
}
output.i().text(key).text(': ').block(error.output);
}
});
});
Expand Down Expand Up @@ -503,12 +498,7 @@ module.exports = function (expect) {
} else {
seenFirstRejected = true;
}
output.i().text(key).text(': ');
if (error._isUnexpected) {
output.block(error.output);
} else {
output.block(output.clone().text(error.message));
}
output.i().text(key).text(': ').block(error.output);
}
});
});
Expand Down
19 changes: 18 additions & 1 deletion test/unexpected.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2404,7 +2404,24 @@ describe('unexpected', function () {
expect([[1], [2]], 'to have items satisfying', 'to have items satisfying', 'to be a number');
});

it('supports legacy legacy', function () {
it('formats non-Unexpected errors correctly', function () {
expect(function () {
expect([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]], 'to have items satisfying', function (item) {
expect.fail(function (output) {
output.text('foo').nl().text('bar');
});
});
}, 'to throw',
'failed expectation in\n' +
'[\n' +
' [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]\n' +
']:\n' +
' 0: foo\n' +
' bar'
);
});

it('supports legacy "to be an array whose items satisfy"', function () {
expect(['0', '1', '2', '3'], 'to be an array whose items satisfy', 'not to be a number');
});

Expand Down

0 comments on commit 533ec97

Please sign in to comment.