mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
Add comments to tests for generic version of jasmine.objectContaining
This commit is contained in:
Vendored
+1
-1
@@ -24,9 +24,9 @@ declare function afterEach(action: (done: DoneFn) => void, timeout?: number): vo
|
||||
declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void;
|
||||
|
||||
declare function expect(spy: Function): jasmine.Matchers<any>;
|
||||
declare function expect<T extends ArrayLike<T>>(actual: ArrayLike<T>): jasmine.ArrayLikeMatchers<T>;
|
||||
declare function expect<T>(actual: T): jasmine.Matchers<T>;
|
||||
declare function expect(spy: Function): jasmine.Matchers<any>;
|
||||
|
||||
declare function fail(e?: any): void;
|
||||
/** Action method that should be called when the async work is complete */
|
||||
|
||||
@@ -679,12 +679,19 @@ describe("jasmine.objectContaining", () => {
|
||||
});
|
||||
|
||||
it("matches objects with the expect key/value pairs", () => {
|
||||
expect(foo).toEqual(jasmine.objectContaining<fooType>({
|
||||
bar: ''
|
||||
// not explictly providing the type on objectContaining only guards against
|
||||
// missmatching types on know properties
|
||||
expect(foo).not.toEqual(jasmine.objectContaining({
|
||||
a: 37,
|
||||
foo: 2, // <-- this does not cause an error as the compiler cannot infer the type completely
|
||||
// b: '123', <-- this would cause an error as `b` defined as number in fooType
|
||||
}));
|
||||
|
||||
expect(foo).not.toEqual(jasmine.objectContaining({
|
||||
a: 37
|
||||
// explictly providing the type on objectContaining makes the guard more precise
|
||||
// as misspelled properties are detected as well
|
||||
expect(foo).not.toEqual(jasmine.objectContaining<fooType>({
|
||||
bar: '',
|
||||
// foo: 1, <-- this would cause an error as `foo` is not defined in fooType
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user