Skip to content

Commit

Permalink
Moved to error assertion tests to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
sunesimonsen committed Dec 25, 2015
1 parent 84cff2b commit 94633fe
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
44 changes: 44 additions & 0 deletions test/assertions/to-error.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*global expect*/
describe('to error assertion', function () {
describe('with a function that throws', function () {
describe('with the "not" flag', function () {
it('should indicate that the function threw', function () {
expect(function () {
expect(function () {
throw new Error('yikes');
}, 'not to error');
}, 'to throw',
"expected function () { throw new Error('yikes'); } not to error\n" +
" threw: Error('yikes')"
);
});
});
});

describe('with a function that returns a promise that is rejected', function () {
describe('with the "not" flag', function () {
it('should indicate that the function returned a rejected promise', function () {
return expect(
expect(function () {
return expect.promise(function (resolve, reject) {
setTimeout(function () {
reject(new Error('wat'));
}, 1);
});
}, 'not to error'),
'to be rejected with',
"expected\n" +
"function () {\n" +
" return expect.promise(function (resolve, reject) {\n" +
" setTimeout(function () {\n" +
" reject(new Error('wat'));\n" +
" }, 1);\n" +
" });\n" +
"}\n" +
"not to error\n" +
" returned promise rejected with: Error('wat')"
);
});
});
});
});
44 changes: 0 additions & 44 deletions test/unexpected.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,50 +120,6 @@ describe('unexpected', function () {
});
});

describe('to error assertion', function () {
describe('with a function that throws', function () {
describe('with the "not" flag', function () {
it('should indicate that the function threw', function () {
expect(function () {
expect(function () {
throw new Error('yikes');
}, 'not to error');
}, 'to throw',
"expected function () { throw new Error('yikes'); } not to error\n" +
" threw: Error('yikes')"
);
});
});
});

describe('with a function that returns a promise that is rejected', function () {
describe('with the "not" flag', function () {
it('should indicate that the function returned a rejected promise', function () {
return expect(
expect(function () {
return expect.promise(function (resolve, reject) {
setTimeout(function () {
reject(new Error('wat'));
}, 1);
});
}, 'not to error'),
'to be rejected with',
"expected\n" +
"function () {\n" +
" return expect.promise(function (resolve, reject) {\n" +
" setTimeout(function () {\n" +
" reject(new Error('wat'));\n" +
" }, 1);\n" +
" });\n" +
"}\n" +
"not to error\n" +
" returned promise rejected with: Error('wat')"
);
});
});
});
});

describe('object type', function () {
describe('#diff', function () {
it('should show identical multiline values correctly in diffs', function () {
Expand Down

0 comments on commit 94633fe

Please sign in to comment.