Merge branch 'custom-object-formatters' into cof-merge-candidate

This commit is contained in:
Steve Gravrock
2020-02-11 11:44:38 -08:00
84 changed files with 3047 additions and 1017 deletions

View File

@@ -115,4 +115,36 @@ describe('Custom Async Matchers (Integration)', function() {
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
it("provides custom equality testers to the matcher factory via matchersUtil", function(done) {
jasmine.getEnv().requirePromises();
var matcherFactory = function (matchersUtil) {
return {
compare: function (actual, expected) {
return Promise.resolve({pass: matchersUtil.equals(actual[0], expected)});
}
};
},
customEqualityFn = jasmine.createSpy("customEqualityFn").and.callFake(function (a, b) {
return a.toString() === b;
});
env.it("spec with expectation", function() {
env.addCustomEqualityTester(customEqualityFn);
env.addAsyncMatchers({
toBeArrayWithFirstElement: matcherFactory
});
return env.expectAsync([1, 2]).toBeArrayWithFirstElement("1");
});
var specExpectations = function(result) {
expect(customEqualityFn).toHaveBeenCalledWith(1, "1");
expect(result.failedExpectations).toEqual([]);
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
});