From c0e76f846ea10b34f3a22a49d33cfa879ea8c0ba Mon Sep 17 00:00:00 2001 From: Simon de Lang Date: Fri, 22 Nov 2019 16:47:01 +0100 Subject: [PATCH] [jasmine] Support Jasmine 3.5 (#40568) * [jasmine] Add EnvConfiguration.failSpecWithNoExpectations property * [jasmine] Add jasmine.addAsyncMatchers * [jasmine] Add jasmine.setDefaultSpyStrategy * [jasmine] Add propertyNames parameter to jasmine.createSpyObj * [jasmine] Add jasmine.toBeInstanceOf matcher * [jasmine] Add jasmine.toBeTrue and jasmine.toBeFalse matchers * [jasmine] Update ts 3.1 types * [jasmine] fix linting issues * [jasmine] add EnvConfiguration.promise function * [jasmine] format tests and remove obsolete test * [jasmine] add toBeRejectedWithError AsyncMatcher * [jasmine] fix toBeRejectedWithError type * [jasmine] fix function formatting * [jasmine] fix test name --- types/jasmine/index.d.ts | 38 ++++++-- types/jasmine/jasmine-tests.ts | 131 +++++++++++++++++++-------- types/jasmine/ts3.1/index.d.ts | 36 ++++++-- types/jasmine/ts3.1/jasmine-tests.ts | 131 +++++++++++++++++++-------- 4 files changed, 245 insertions(+), 91 deletions(-) diff --git a/types/jasmine/index.d.ts b/types/jasmine/index.d.ts index 0fcb1fa189..ce699c183a 100644 --- a/types/jasmine/index.d.ts +++ b/types/jasmine/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Jasmine 3.4 +// Type definitions for Jasmine 3.5 // Project: http://jasmine.github.io // Definitions by: Boris Yankov // Theodore Brown @@ -204,6 +204,11 @@ declare namespace jasmine { (ReadonlyArray | { [methodName: string]: any }) : (ReadonlyArray | { [P in keyof T]?: T[P] extends Func ? ReturnType : any }); + type SpyObjPropertyNames = + T extends undefined ? + (ReadonlyArray | { [propertyName: string]: any }) : + (ReadonlyArray); + /** * Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure} */ @@ -211,9 +216,11 @@ declare namespace jasmine { random?: boolean; seed?: number; failFast?: boolean; + failSpecWithNoExpectations?: boolean; oneFailurePerSpec?: boolean; hideDisabled?: boolean; specFilter?: Function; + promise?: Function; } function clock(): Clock; @@ -257,13 +264,13 @@ declare namespace jasmine { function arrayContaining(sample: ArrayLike): ArrayContaining; function arrayWithExactContents(sample: ArrayLike): ArrayContaining; function objectContaining(sample: Partial): ObjectContaining; + + function setDefaultSpyStrategy(and: SpyAnd): void; function createSpy(name?: string, originalFn?: Function): Spy; - - function createSpyObj(baseName: string, methodNames: SpyObjMethodNames): any; - function createSpyObj(baseName: string, methodNames: SpyObjMethodNames): SpyObj; - - function createSpyObj(methodNames: SpyObjMethodNames): any; - function createSpyObj(methodNames: SpyObjMethodNames): SpyObj; + function createSpyObj(baseName: string, methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any; + function createSpyObj(baseName: string, methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): SpyObj; + function createSpyObj(methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any; + function createSpyObj(methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): SpyObj; function pp(value: any): string; @@ -272,6 +279,7 @@ declare namespace jasmine { function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; function addMatchers(matchers: CustomMatcherFactories): void; + function addAsyncMatchers(matchers: CustomMatcherFactories): void; function stringMatching(str: string | RegExp): AsymmetricMatcher; @@ -564,6 +572,8 @@ declare namespace jasmine { toBeNaN(): boolean; toBeTruthy(expectationFailOutput?: any): boolean; toBeFalsy(expectationFailOutput?: any): boolean; + toBeTrue(): boolean; + toBeFalse(): boolean; toHaveBeenCalled(): boolean; toHaveBeenCalledBefore(expected: Spy): boolean; toHaveBeenCalledWith(...params: any[]): boolean; @@ -580,6 +590,7 @@ declare namespace jasmine { toThrowMatching(predicate: (thrown: any) => boolean): boolean; toBeNegativeInfinity(expectationFailOutput?: any): boolean; toBePositiveInfinity(expectationFailOutput?: any): boolean; + toBeInstanceOf(expected: Constructor): boolean; /** * Expect the actual value to be a DOM element that has the expected class. @@ -667,6 +678,19 @@ declare namespace jasmine { */ toBeRejectedWith(expected: Expected): PromiseLike; + /** + * Expect a promise to be rejected with a value matched to the expected. + * @param expected - Error constructor the object that was thrown needs to be an instance of. If not provided, Error will be used. + * @param message - The message that should be set on the thrown Error. + */ + toBeRejectedWithError(expected?: new (...args: any[]) => Error, message?: string | RegExp): PromiseLike; + + /** + * Expect a promise to be rejected with a value matched to the expected. + * @param message - The message that should be set on the thrown Error. + */ + toBeRejectedWithError(message?: string | RegExp): PromiseLike; + /** * Add some context for an expect. * @param message - Additional context to show when the matcher fails. diff --git a/types/jasmine/jasmine-tests.ts b/types/jasmine/jasmine-tests.ts index 117b25dcf1..38ae311d96 100644 --- a/types/jasmine/jasmine-tests.ts +++ b/types/jasmine/jasmine-tests.ts @@ -59,7 +59,7 @@ describe("Included matchers:", () => { }); it("should work for optional values", () => { - const opt: string | undefined = Math.random() > .5 ? "s" : undefined; + const opt: string | undefined = Math.random() > .5 ? "s" : undefined; expect(opt).toEqual(undefined); }); }); @@ -115,6 +115,18 @@ describe("Included matchers:", () => { expect(foo).not.toBeFalsy(); }); + it("The 'toBeTrue' matcher is for matching with true", () => { + expect(true).toBeTrue(); + expect(false).not.toBeTrue(); + expect({}).not.toBeTrue(); + }); + + it("The 'toBeFalse' matcher is for matching with false", () => { + expect(false).toBeFalse(); + expect(true).not.toBeFalse(); + expect(undefined).not.toBeFalse(); + }); + it("The 'toContain' matcher is for finding an item in an Array", () => { const a = ["foo", "bar", "baz"]; @@ -179,6 +191,15 @@ describe("Included matchers:", () => { expect(foo).toThrowError(TypeError, "foo bar baz"); }); + it("The 'toBeInstanceOf' matcher is for testing if the actual is of the expected class", () => { + class MyClass { } + + expect(new MyClass()).toBeInstanceOf(MyClass); + expect('foo').toBeInstanceOf(String); + expect(3).toBeInstanceOf(Number); + expect(new Error()).toBeInstanceOf(Error); + }); + it("async matchers", async () => { const badness = new Error("badness"); await expectAsync(Promise.resolve()).toBeResolved(); @@ -187,6 +208,11 @@ describe("Included matchers:", () => { await expectAsync(Promise.reject(badness)).toBeRejected(); await expectAsync(Promise.reject(badness)).toBeRejected("bad mojo"); await expectAsync(Promise.reject(badness)).toBeRejectedWith(badness); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error, "badness"); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error, /badness/); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError("badness"); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError(/badness/); await expectAsync(Promise.resolve()).withContext("additional info").toBeResolved(); }); @@ -197,6 +223,10 @@ describe("Included matchers:", () => { await expectAsync(Promise.resolve(true)).not.toBeResolvedTo(false); await expectAsync(Promise.resolve()).not.toBeRejected(); await expectAsync(Promise.reject(badness)).not.toBeRejectedWith(malady); + await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(Error, "malady"); + await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(Error, /malady/); + await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError("malady"); + await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(/malady/); await expectAsync(Promise.reject(badness)).not.withContext("additional info").toBeResolved(); await expectAsync(Promise.reject(badness)).withContext("additional info").not.toBeResolved(); }); @@ -991,7 +1021,7 @@ describe("jasmine.objectContaining", () => { }; expect(nestedFoo).toEqual({ - nested: jasmine.objectContaining({b: 2}) + nested: jasmine.objectContaining({ b: 2 }) }); }); @@ -1326,25 +1356,25 @@ describe('better typed spys', () => { const spy = spyOn(foo, 'method'); const spy2 = spyOn(foo, 'value'); // Is an error with TS 3.1+ typings. - // $ExpectType any + // $ExpectType any spy.calls.first().returnValue; }); it('works on constructors', () => { class MyClass { - constructor(readonly foo: string) {} + constructor(readonly foo: string) { } } const namespace = { MyClass }; const spy = spyOn(namespace, 'MyClass'); - spy.and.returnValue({foo: 'test'}); + spy.and.returnValue({ foo: 'test' }); spy.and.returnValue({}); // Is an error with TS 3.1+ typings. - spy.and.returnValue({foo: 123}); // Is an error with TS 3.1+ typings. + spy.and.returnValue({ foo: 123 }); // Is an error with TS 3.1+ typings. }); it('can allows overriding the generic', () => { class Base { - service() {} + service() { } } class Super extends Base { - service2() {} + service2() { } } spyOn(new Super(), 'service'); spyOn(new Super(), 'service2'); // $ExpectError @@ -1433,7 +1463,7 @@ describe("Randomize Tests", () => { // Dest spces copied from jasmine project (https://github.com/jasmine/jasmine/blob/master/spec/core/SpecSpec.js) describe("createSpyObj", function() { it("should create an object with spy methods and corresponding return values when you call jasmine.createSpyObj() with an object", function() { - const spyObj = jasmine.createSpyObj('BaseName', {method1: 42, method2: 'special sauce'}); + const spyObj = jasmine.createSpyObj('BaseName', { method1: 42, method2: 'special sauce' }); expect(spyObj.method1()).toEqual(42); expect(spyObj.method1.and.identity()).toEqual('BaseName.method1'); @@ -1451,7 +1481,7 @@ describe("createSpyObj", function() { }); it("should allow you to omit the baseName and takes only an object", function() { - const spyObj = jasmine.createSpyObj({method1: 42, method2: 'special sauce'}); + const spyObj = jasmine.createSpyObj({ method1: 42, method2: 'special sauce' }); expect(spyObj.method1()).toEqual(42); expect(spyObj.method1.and.identity()).toEqual('unknown.method1'); @@ -1479,47 +1509,70 @@ describe("createSpyObj", function() { jasmine.createSpyObj('BaseName', {}); }).toThrow("createSpyObj requires a non-empty array or object of method names to create spies for"); }); + + it("creates an object with property names and return values if second object is passed", function() { + const spyObj = jasmine.createSpyObj('base', ['method1'], { + prop1: 'foo', + prop2: 37 + }); + + expect(spyObj).toEqual({ + method1: jasmine.any(Function) + }); + + expect(spyObj.prop1).toEqual('foo'); + expect(spyObj.prop2).toEqual(37); + spyObj.prop2 = 4; + expect(spyObj.prop2).toEqual(37); + }); + + it("allows base name to be ommitted when assigning methods and properties", function() { + const spyObj = jasmine.createSpyObj({ m: 3 }, { p: 4 }); + + expect(spyObj.m()).toEqual(3); + expect(spyObj.p).toEqual(4); + }); }); describe('Static Matcher Test', function() { it('Falsy', () => { - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: jasmine.falsy(), - }) - ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: jasmine.falsy(), + }) + ); }); it('Truthy', () => { - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: jasmine.truthy(), - }) - ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: jasmine.truthy(), + }) + ); }); it('Empty', () => { - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: jasmine.empty(), - }) - ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: jasmine.empty(), + }) + ); }); it('NotEmpty', () => { - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: jasmine.notEmpty(), - }) - ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: jasmine.notEmpty(), + }) + ); }); it('Partial should OK', () => { - expect({ value: null, label: 'abcd' }).toEqual( - jasmine.objectContaining({ - value: jasmine.anything(), - }) - ); - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: 'any value should ok', - }) + expect({ value: null, label: 'abcd' }).toEqual( + jasmine.objectContaining({ + value: jasmine.anything(), + }) + ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: 'any value should ok', + }) ); }); }); diff --git a/types/jasmine/ts3.1/index.d.ts b/types/jasmine/ts3.1/index.d.ts index 172c0fb082..5d90a2f6be 100644 --- a/types/jasmine/ts3.1/index.d.ts +++ b/types/jasmine/ts3.1/index.d.ts @@ -207,6 +207,11 @@ declare namespace jasmine { (ReadonlyArray | { [methodName: string]: any }) : (ReadonlyArray | { [P in keyof T]?: T[P] extends Func ? ReturnType : any }); + type SpyObjPropertyNames = + T extends undefined ? + (ReadonlyArray | { [propertyName: string]: any }) : + (ReadonlyArray); + /** * Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure} */ @@ -214,9 +219,11 @@ declare namespace jasmine { random?: boolean; seed?: number; failFast?: boolean; + failSpecWithNoExpectations?: boolean; oneFailurePerSpec?: boolean; hideDisabled?: boolean; specFilter?: Function; + promise?: Function; } function clock(): Clock; @@ -260,13 +267,13 @@ declare namespace jasmine { function arrayContaining(sample: ArrayLike): ArrayContaining; function arrayWithExactContents(sample: ArrayLike): ArrayContaining; function objectContaining(sample: Partial): ObjectContaining; + + function setDefaultSpyStrategy(and: SpyAnd): void; function createSpy(name?: string, originalFn?: Fn): Spy; - - function createSpyObj(baseName: string, methodNames: SpyObjMethodNames): any; - function createSpyObj(baseName: string, methodNames: SpyObjMethodNames): SpyObj; - - function createSpyObj(methodNames: SpyObjMethodNames): any; - function createSpyObj(methodNames: SpyObjMethodNames): SpyObj; + function createSpyObj(baseName: string, methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any; + function createSpyObj(baseName: string, methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): SpyObj; + function createSpyObj(methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any; + function createSpyObj(methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): SpyObj; function pp(value: any): string; @@ -275,6 +282,7 @@ declare namespace jasmine { function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; function addMatchers(matchers: CustomMatcherFactories): void; + function addAsyncMatchers(matchers: CustomMatcherFactories): void; function stringMatching(str: string | RegExp): AsymmetricMatcher; @@ -567,6 +575,8 @@ declare namespace jasmine { toBeNaN(): boolean; toBeTruthy(expectationFailOutput?: any): boolean; toBeFalsy(expectationFailOutput?: any): boolean; + toBeTrue(): boolean; + toBeFalse(): boolean; toHaveBeenCalled(): boolean; toHaveBeenCalledBefore(expected: Func): boolean; toHaveBeenCalledWith(...params: any[]): boolean; @@ -583,6 +593,7 @@ declare namespace jasmine { toThrowMatching(predicate: (thrown: any) => boolean): boolean; toBeNegativeInfinity(expectationFailOutput?: any): boolean; toBePositiveInfinity(expectationFailOutput?: any): boolean; + toBeInstanceOf(expected: Constructor): boolean; /** * Expect the actual value to be a DOM element that has the expected class. @@ -687,6 +698,19 @@ declare namespace jasmine { */ toBeRejectedWith(expected: Expected): Promise; + /** + * Expect a promise to be rejected with a value matched to the expected. + * @param expected - Error constructor the object that was thrown needs to be an instance of. If not provided, Error will be used. + * @param message - The message that should be set on the thrown Error. + */ + toBeRejectedWithError(expected?: new (...args: any[]) => Error, message?: string | RegExp): Promise; + + /** + * Expect a promise to be rejected with a value matched to the expected. + * @param message - The message that should be set on the thrown Error. + */ + toBeRejectedWithError(message?: string | RegExp): Promise; + /** * Add some context for an expect. * @param message - Additional context to show when the matcher fails. diff --git a/types/jasmine/ts3.1/jasmine-tests.ts b/types/jasmine/ts3.1/jasmine-tests.ts index 327ebb8ab1..7ade304397 100644 --- a/types/jasmine/ts3.1/jasmine-tests.ts +++ b/types/jasmine/ts3.1/jasmine-tests.ts @@ -59,7 +59,7 @@ describe("Included matchers:", () => { }); it("should work for optional values", () => { - const opt: string | undefined = Math.random() > .5 ? "s" : undefined; + const opt: string | undefined = Math.random() > .5 ? "s" : undefined; expect(opt).toEqual(undefined); }); }); @@ -115,6 +115,18 @@ describe("Included matchers:", () => { expect(foo).not.toBeFalsy(); }); + it("The 'toBeTrue' matcher is for matching with true", () => { + expect(true).toBeTrue(); + expect(false).not.toBeTrue(); + expect({}).not.toBeTrue(); + }); + + it("The 'toBeFalse' matcher is for matching with false", () => { + expect(false).toBeFalse(); + expect(true).not.toBeFalse(); + expect(undefined).not.toBeFalse(); + }); + it("The 'toContain' matcher is for finding an item in an Array", () => { const a = ["foo", "bar", "baz"]; @@ -179,6 +191,15 @@ describe("Included matchers:", () => { expect(foo).toThrowError(TypeError, "foo bar baz"); }); + it("The 'toBeInstanceOf' matcher is for testing if the actual is of the expected class", () => { + class MyClass { } + + expect(new MyClass()).toBeInstanceOf(MyClass); + expect('foo').toBeInstanceOf(String); + expect(3).toBeInstanceOf(Number); + expect(new Error()).toBeInstanceOf(Error); + }); + it("async matchers", async () => { const badness = new Error("badness"); await expectAsync(Promise.resolve()).toBeResolved(); @@ -187,6 +208,11 @@ describe("Included matchers:", () => { await expectAsync(Promise.reject(badness)).toBeRejected(); await expectAsync(Promise.reject(badness)).toBeRejected("bad mojo"); await expectAsync(Promise.reject(badness)).toBeRejectedWith(badness); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error, "badness"); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error, /badness/); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError("badness"); + await expectAsync(Promise.reject(badness)).toBeRejectedWithError(/badness/); await expectAsync(Promise.resolve()).withContext("additional info").toBeResolved(); }); @@ -197,6 +223,10 @@ describe("Included matchers:", () => { await expectAsync(Promise.resolve(true)).not.toBeResolvedTo(false); await expectAsync(Promise.resolve()).not.toBeRejected(); await expectAsync(Promise.reject(badness)).not.toBeRejectedWith(malady); + await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(Error, "malady"); + await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(Error, /malady/); + await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError("malady"); + await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(/malady/); await expectAsync(Promise.reject(badness)).not.withContext("additional info").toBeResolved(); await expectAsync(Promise.reject(badness)).withContext("additional info").not.toBeResolved(); }); @@ -991,7 +1021,7 @@ describe("jasmine.objectContaining", () => { }; expect(nestedFoo).toEqual({ - nested: jasmine.objectContaining({b: 2}) + nested: jasmine.objectContaining({ b: 2 }) }); }); @@ -1326,25 +1356,25 @@ describe('better typed spys', () => { const spy = spyOn(foo, 'method'); const spy2 = spyOn(foo, 'value'); // $ExpectError - // $ExpectType string + // $ExpectType string spy.calls.first().returnValue; }); it('works on constructors', () => { class MyClass { - constructor(readonly foo: string) {} + constructor(readonly foo: string) { } } const namespace = { MyClass }; const spy = spyOn(namespace, 'MyClass'); - spy.and.returnValue({foo: 'test'}); + spy.and.returnValue({ foo: 'test' }); spy.and.returnValue({}); // $ExpectError - spy.and.returnValue({foo: 123}); // $ExpectError + spy.and.returnValue({ foo: 123 }); // $ExpectError }); it('can allows overriding the generic', () => { class Base { - service() {} + service() { } } class Super extends Base { - service2() {} + service2() { } } spyOn(new Super(), 'service'); spyOn(new Super(), 'service2'); // $ExpectError @@ -1433,7 +1463,7 @@ describe("Randomize Tests", () => { // Dest spces copied from jasmine project (https://github.com/jasmine/jasmine/blob/master/spec/core/SpecSpec.js) describe("createSpyObj", function() { it("should create an object with spy methods and corresponding return values when you call jasmine.createSpyObj() with an object", function() { - const spyObj = jasmine.createSpyObj('BaseName', {method1: 42, method2: 'special sauce'}); + const spyObj = jasmine.createSpyObj('BaseName', { method1: 42, method2: 'special sauce' }); expect(spyObj.method1()).toEqual(42); expect(spyObj.method1.and.identity()).toEqual('BaseName.method1'); @@ -1451,7 +1481,7 @@ describe("createSpyObj", function() { }); it("should allow you to omit the baseName and takes only an object", function() { - const spyObj = jasmine.createSpyObj({method1: 42, method2: 'special sauce'}); + const spyObj = jasmine.createSpyObj({ method1: 42, method2: 'special sauce' }); expect(spyObj.method1()).toEqual(42); expect(spyObj.method1.and.identity()).toEqual('unknown.method1'); @@ -1479,47 +1509,70 @@ describe("createSpyObj", function() { jasmine.createSpyObj('BaseName', {}); }).toThrow("createSpyObj requires a non-empty array or object of method names to create spies for"); }); + + it("creates an object with property names and return values if second object is passed", function() { + const spyObj = jasmine.createSpyObj('base', ['method1'], { + prop1: 'foo', + prop2: 37 + }); + + expect(spyObj).toEqual({ + method1: jasmine.any(Function) + }); + + expect(spyObj.prop1).toEqual('foo'); + expect(spyObj.prop2).toEqual(37); + spyObj.prop2 = 4; + expect(spyObj.prop2).toEqual(37); + }); + + it("allows base name to be ommitted when assigning methods and properties", function() { + const spyObj = jasmine.createSpyObj({ m: 3 }, { p: 4 }); + + expect(spyObj.m()).toEqual(3); + expect(spyObj.p).toEqual(4); + }); }); describe('Static Matcher Test', function() { it('Falsy', () => { - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: jasmine.falsy(), - }) - ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: jasmine.falsy(), + }) + ); }); it('Truthy', () => { - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: jasmine.truthy(), - }) - ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: jasmine.truthy(), + }) + ); }); it('Empty', () => { - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: jasmine.empty(), - }) - ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: jasmine.empty(), + }) + ); }); it('NotEmpty', () => { - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: jasmine.notEmpty(), - }) - ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: jasmine.notEmpty(), + }) + ); }); it('Partial should OK', () => { - expect({ value: null, label: 'abcd' }).toEqual( - jasmine.objectContaining({ - value: jasmine.anything(), - }) - ); - expect({ value: null }).toEqual( - jasmine.objectContaining({ - value: 'any value should ok', - }) + expect({ value: null, label: 'abcd' }).toEqual( + jasmine.objectContaining({ + value: jasmine.anything(), + }) + ); + expect({ value: null }).toEqual( + jasmine.objectContaining({ + value: 'any value should ok', + }) ); }); });