The old style of merging all of a function's variable declarations into a single statement made some sense back in the days of var, but there's no reason to keep doing it now that we use const and let.
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
describe('toBeRejected', function() {
|
|
it('passes if the actual is rejected', function() {
|
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
|
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
|
const actual = Promise.reject('AsyncExpectationSpec rejection');
|
|
|
|
return matcher.compare(actual).then(function(result) {
|
|
expect(result).toEqual(jasmine.objectContaining({ pass: true }));
|
|
});
|
|
});
|
|
|
|
it('fails if the actual is resolved', function() {
|
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
|
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
|
const actual = Promise.resolve();
|
|
|
|
return matcher.compare(actual).then(function(result) {
|
|
expect(result).toEqual(jasmine.objectContaining({ pass: false }));
|
|
});
|
|
});
|
|
|
|
it('fails if actual is not a promise', function() {
|
|
const matchersUtil = new privateUnderTest.MatchersUtil();
|
|
const matcher = privateUnderTest.asyncMatchers.toBeRejected(matchersUtil);
|
|
const actual = 'not a promise';
|
|
|
|
function f() {
|
|
return matcher.compare(actual);
|
|
}
|
|
|
|
expect(f).toThrowError(
|
|
'Expected toBeRejected to be called on a promise but was on a string.'
|
|
);
|
|
});
|
|
});
|