Use Partial keyword for objectContaining

This commit is contained in:
Lukas Zech
2017-02-23 13:25:02 +01:00
parent 89328a754d
commit df8b672c7a
2 changed files with 12 additions and 7 deletions
+3 -3
View File
@@ -49,7 +49,7 @@ declare namespace jasmine {
function any(aclass: any): Any;
function anything(): Any;
function arrayContaining(sample: any[]): ArrayContaining;
function objectContaining(sample: any): ObjectContaining;
function objectContaining<T>(sample: Partial<T>): ObjectContaining<T>;
function createSpy(name: string, originalFn?: Function): Spy;
function createSpyObj(baseName: string, methodNames: any[]): any;
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
@@ -82,8 +82,8 @@ declare namespace jasmine {
jasmineToString(): string;
}
interface ObjectContaining {
new (sample: any): any;
interface ObjectContaining<T> {
new (sample: Partial<T>): T;
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
jasmineToString(): string;
+9 -4
View File
@@ -663,7 +663,12 @@ describe("jasmine.any", function () {
});
describe("jasmine.objectContaining", function () {
var foo: any;
interface fooType {
a:number;
b:number;
bar:string;
}
var foo: fooType;
beforeEach(function () {
foo = {
@@ -674,11 +679,11 @@ describe("jasmine.objectContaining", function () {
});
it("matches objects with the expect key/value pairs", function () {
expect(foo).toEqual(jasmine.objectContaining({
expect(foo).toEqual(jasmine.objectContaining<fooType>({
bar: "baz"
}));
expect(foo).not.toEqual(jasmine.objectContaining({
c: 37
expect(foo).not.toEqual(jasmine.objectContaining<fooType>({
a: 37
}));
});