diff --git a/types/jasmine/index.d.ts b/types/jasmine/index.d.ts index 838bf63e15..e0bb403a1f 100644 --- a/types/jasmine/index.d.ts +++ b/types/jasmine/index.d.ts @@ -236,17 +236,17 @@ declare namespace jasmine { } interface ArrayContaining { - new (sample: ArrayLike): ArrayLike; + new?(sample: ArrayLike): ArrayLike; asymmetricMatch(other: any): boolean; - jasmineToString(): string; + jasmineToString?(): string; } interface ObjectContaining { - new (sample: Partial): Partial; + new?(sample: Partial): Partial; jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; - jasmineToString(): string; + jasmineToString?(): string; } interface Block { diff --git a/types/jasmine/jasmine-tests.ts b/types/jasmine/jasmine-tests.ts index 28aa9470fe..c5e1393453 100644 --- a/types/jasmine/jasmine-tests.ts +++ b/types/jasmine/jasmine-tests.ts @@ -837,6 +837,29 @@ describe("jasmine.any", () => { }); }); +describe('custom asymmetry', function() { + const tester = { + asymmetricMatch: (actual: string) => { + const secondValue = actual.split(',')[1]; + return secondValue === 'bar'; + }, + }; + + it('dives in deep', function() { + expect('foo,bar,baz,quux').toEqual(tester); + }); + + describe('when used with a spy', function() { + it('is useful for comparing arguments', function() { + const callback = jasmine.createSpy('callback'); + + callback('foo,bar,baz'); + + expect(callback).toHaveBeenCalledWith(tester); + }); + }); +}); + describe("jasmine.objectContaining", () => { interface fooType { a: number; diff --git a/types/jasmine/ts3.1/index.d.ts b/types/jasmine/ts3.1/index.d.ts index 055a0e18b1..096de3ee11 100644 --- a/types/jasmine/ts3.1/index.d.ts +++ b/types/jasmine/ts3.1/index.d.ts @@ -245,17 +245,17 @@ declare namespace jasmine { } interface ArrayContaining { - new (sample: ArrayLike): ArrayLike; + new?(sample: ArrayLike): ArrayLike; asymmetricMatch(other: any): boolean; - jasmineToString(): string; + jasmineToString?(): string; } interface ObjectContaining { - new (sample: Partial): Partial; + new?(sample: Partial): Partial; jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; - jasmineToString(): string; + jasmineToString?(): string; } interface Block { diff --git a/types/jasmine/ts3.1/jasmine-tests.ts b/types/jasmine/ts3.1/jasmine-tests.ts index 14f131422f..651f0a3bef 100644 --- a/types/jasmine/ts3.1/jasmine-tests.ts +++ b/types/jasmine/ts3.1/jasmine-tests.ts @@ -839,6 +839,29 @@ describe("jasmine.any", () => { }); }); +describe('custom asymmetry', function() { + const tester = { + asymmetricMatch: (actual: string) => { + const secondValue = actual.split(',')[1]; + return secondValue === 'bar'; + }, + }; + + it('dives in deep', function() { + expect('foo,bar,baz,quux').toEqual(tester); + }); + + describe('when used with a spy', function() { + it('is useful for comparing arguments', function() { + const callback = jasmine.createSpy('callback'); + + callback('foo,bar,baz'); + + expect(callback).toHaveBeenCalledWith(tester); + }); + }); +}); + describe("jasmine.objectContaining", () => { interface fooType { a: number;