Fix and enable pending async expectation message spec

This commit is contained in:
Steve Gravrock
2025-08-30 13:02:08 -07:00
parent 09ce3a30b6
commit b597975c7e

View File

@@ -129,34 +129,34 @@ describe('AsyncExpectation', function() {
}); });
}); });
it('prepends the context to a custom failure message from a function', function() { it('prepends the context to a custom failure message from a matcher', async function() {
pending('should actually work, but no custom matchers for async yet');
const matchersUtil = { const matchersUtil = {
buildFailureMessage: function() { buildFailureMessage() {
return 'failure message'; return 'failure message';
}
}, },
addExpectationResult = jasmine.createSpy('addExpectationResult'), pp(v) {
actual = Promise.reject(new Error('nope')), return v.toString();
expectation = jasmineUnderTest.Expectation.asyncFactory({ }
};
const addExpectationResult = jasmine.createSpy('addExpectationResult');
const actual = Promise.reject(new Error('nope'));
const expectation = jasmineUnderTest.Expectation.asyncFactory({
actual: actual, actual: actual,
addExpectationResult: addExpectationResult, addExpectationResult: addExpectationResult,
matchersUtil: matchersUtil matchersUtil: matchersUtil
}); });
return expectation await expectation.withContext('Some context').toBeResolved();
.withContext('Some context')
.toBeResolved()
.then(function() {
expect(addExpectationResult).toHaveBeenCalledWith( expect(addExpectationResult).toHaveBeenCalledWith(
false, false,
jasmine.objectContaining({ jasmine.objectContaining({
message: 'Some context: msg' message:
'Some context: Expected a promise to be resolved but it ' +
'was rejected with Error: nope.'
}) })
); );
}); });
});
it('works with #not', function() { it('works with #not', function() {
const addExpectationResult = jasmine.createSpy('addExpectationResult'), const addExpectationResult = jasmine.createSpy('addExpectationResult'),