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,33 +129,33 @@ 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({ }
actual: actual, };
addExpectationResult: addExpectationResult, const addExpectationResult = jasmine.createSpy('addExpectationResult');
matchersUtil: matchersUtil const actual = Promise.reject(new Error('nope'));
}); const expectation = jasmineUnderTest.Expectation.asyncFactory({
actual: actual,
addExpectationResult: addExpectationResult,
matchersUtil: matchersUtil
});
return expectation await expectation.withContext('Some context').toBeResolved();
.withContext('Some context')
.toBeResolved() expect(addExpectationResult).toHaveBeenCalledWith(
.then(function() { false,
expect(addExpectationResult).toHaveBeenCalledWith( jasmine.objectContaining({
false, message:
jasmine.objectContaining({ 'Some context: Expected a promise to be resolved but it ' +
message: 'Some context: msg' 'was rejected with Error: nope.'
}) })
); );
});
}); });
it('works with #not', function() { it('works with #not', function() {