Add custom async matchers

This commit is contained in:
Tony Brix
2019-07-08 15:13:06 -05:00
committed by Steve Gravrock
parent 008b80adc5
commit f77ee32c56
18 changed files with 876 additions and 49 deletions

View File

@@ -20,4 +20,17 @@ describe('toBeRejected', function() {
expect(result).toEqual(jasmine.objectContaining({pass: false}));
});
});
it('fails if actual is not a promise', function() {
var matcher = jasmineUnderTest.asyncMatchers.toBeRejected(jasmineUnderTest.matchersUtil),
actual = 'not a promise';
function f() {
return matcher.compare(actual);
}
expect(f).toThrowError(
'Expected toBeRejected to be called on a promise.'
);
});
});

View File

@@ -138,4 +138,17 @@ describe('#toBeRejectedWithError', function () {
}));
});
});
it('fails if actual is not a promise', function() {
var matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(jasmineUnderTest.matchersUtil),
actual = 'not a promise';
function f() {
return matcher.compare(actual);
}
expect(f).toThrowError(
'Expected toBeRejectedWithError to be called on a promise.'
);
});
});

View File

@@ -60,4 +60,17 @@ describe('#toBeRejectedWith', function () {
expect(result).toEqual(jasmine.objectContaining({pass: true}));
});
});
it('fails if actual is not a promise', function() {
var matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWith(jasmineUnderTest.matchersUtil),
actual = 'not a promise';
function f() {
return matcher.compare(actual);
}
expect(f).toThrowError(
'Expected toBeRejectedWith to be called on a promise.'
);
});
});

View File

@@ -20,4 +20,17 @@ describe('toBeResolved', function() {
expect(result).toEqual(jasmine.objectContaining({pass: false}));
});
});
it('fails if actual is not a promise', function() {
var matcher = jasmineUnderTest.asyncMatchers.toBeResolved(jasmineUnderTest.matchersUtil),
actual = 'not a promise';
function f() {
return matcher.compare(actual);
}
expect(f).toThrowError(
'Expected toBeResolved to be called on a promise.'
);
});
});

View File

@@ -63,4 +63,17 @@ describe('#toBeResolvedTo', function() {
expect(result).toEqual(jasmine.objectContaining({pass: true}));
});
});
it('fails if actual is not a promise', function() {
var matcher = jasmineUnderTest.asyncMatchers.toBeResolvedTo(jasmineUnderTest.matchersUtil),
actual = 'not a promise';
function f() {
return matcher.compare(actual);
}
expect(f).toThrowError(
'Expected toBeResolvedTo to be called on a promise.'
);
});
});