Added integration tests for asymmetric equality testers

This commit is contained in:
Steve Gravrock
2019-09-22 12:07:23 -07:00
parent 223924a7a1
commit 795a80ec66
4 changed files with 249 additions and 12 deletions
+21 -6
View File
@@ -261,7 +261,10 @@ describe('Matchers (Integration)', function() {
describe('toBeResolvedTo', function() {
verifyPassesAsync(function(env) {
return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('foo');
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5);
});
verifyFailsAsync(function(env) {
@@ -281,7 +284,10 @@ describe('Matchers (Integration)', function() {
describe('toBeRejectedWith', function() {
verifyPassesAsync(function(env) {
return env.expectAsync(Promise.reject('nope')).toBeRejectedWith('nope');
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5);
});
verifyFailsAsync(function(env) {
@@ -331,7 +337,10 @@ describe('Matchers (Integration)', function() {
describe('toContain', function() {
verifyPasses(function(env) {
env.expect('foobar').toContain('oo');
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
env.expect(['1', '2', '3']).toContain(2);
});
verifyFails(function(env) {
@@ -341,7 +350,10 @@ describe('Matchers (Integration)', function() {
describe('toEqual', function() {
verifyPasses(function(env) {
env.expect('a').toEqual('a');
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
env.expect(5).toEqual('5');
});
verifyFails(function(env) {
@@ -394,8 +406,11 @@ describe('Matchers (Integration)', function() {
describe('toHaveBeenCalledWith', function() {
verifyPasses(function(env) {
var spy = env.createSpy();
spy('foo');
env.expect(spy).toHaveBeenCalledWith('foo');
spy('5');
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
env.expect(spy).toHaveBeenCalledWith(5);
});
verifyFails(function(env) {