mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
fix types for jasmine: allow partial properties when using objects (#42363)
Source reference from Jasmine:
a6a9550d1e/src/core/SpyFactory.js (L38-L49)
This commit is contained in:
parent
d66b9a5834
commit
edfa6cda4e
2
types/jasmine/index.d.ts
vendored
2
types/jasmine/index.d.ts
vendored
@ -207,7 +207,7 @@ declare namespace jasmine {
|
||||
type SpyObjPropertyNames<T = undefined> =
|
||||
T extends undefined ?
|
||||
(ReadonlyArray<string> | { [propertyName: string]: any }) :
|
||||
(ReadonlyArray<keyof T>);
|
||||
(ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] });
|
||||
|
||||
/**
|
||||
* Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure}
|
||||
|
||||
@ -1563,6 +1563,36 @@ describe("createSpyObj", function() {
|
||||
expect(spyObj.m()).toEqual(3);
|
||||
expect(spyObj.p).toEqual(4);
|
||||
});
|
||||
|
||||
it("allows methods and properties lists to omit entries from typed object", function() {
|
||||
interface Template {
|
||||
method1(): number;
|
||||
method2(): void;
|
||||
readonly property1: string;
|
||||
property2: number;
|
||||
}
|
||||
const spyObj = jasmine.createSpyObj<Template>(["method1"], ["property1"]);
|
||||
|
||||
expect(spyObj).toEqual({
|
||||
method1: jasmine.any(Function),
|
||||
method2: undefined as any,
|
||||
property1: undefined as any,
|
||||
property2: undefined as any
|
||||
});
|
||||
});
|
||||
|
||||
it("allows methods and properties objects to omit entries from typed object", function() {
|
||||
interface Template {
|
||||
method1(): number;
|
||||
method2(): void;
|
||||
readonly property1: string;
|
||||
property2: number;
|
||||
}
|
||||
const spyObj = jasmine.createSpyObj<Template>({method1: 3}, {property1: "4"});
|
||||
|
||||
expect(spyObj.method1()).toEqual(3);
|
||||
expect(spyObj.property1).toEqual("4");
|
||||
});
|
||||
});
|
||||
|
||||
describe('Static Matcher Test', function() {
|
||||
|
||||
2
types/jasmine/ts3.1/index.d.ts
vendored
2
types/jasmine/ts3.1/index.d.ts
vendored
@ -210,7 +210,7 @@ declare namespace jasmine {
|
||||
type SpyObjPropertyNames<T = undefined> =
|
||||
T extends undefined ?
|
||||
(ReadonlyArray<string> | { [propertyName: string]: any }) :
|
||||
(ReadonlyArray<keyof T>);
|
||||
(ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] });
|
||||
|
||||
/**
|
||||
* Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure}
|
||||
|
||||
@ -1532,6 +1532,36 @@ describe("createSpyObj", function() {
|
||||
expect(spyObj.m()).toEqual(3);
|
||||
expect(spyObj.p).toEqual(4);
|
||||
});
|
||||
|
||||
it("allows methods and properties lists to omit entries from typed object", function() {
|
||||
interface Template {
|
||||
method1(): number;
|
||||
method2(): void;
|
||||
readonly property1: string;
|
||||
property2: number;
|
||||
}
|
||||
const spyObj = jasmine.createSpyObj<Template>(["method1"], ["property1"]);
|
||||
|
||||
expect(spyObj).toEqual({
|
||||
method1: jasmine.any(Function),
|
||||
method2: undefined as any,
|
||||
property1: undefined as any,
|
||||
property2: undefined as any
|
||||
});
|
||||
});
|
||||
|
||||
it("allows methods and properties objects to omit entries from typed object", function() {
|
||||
interface Template {
|
||||
method1(): number;
|
||||
method2(): void;
|
||||
readonly property1: string;
|
||||
property2: number;
|
||||
}
|
||||
const spyObj = jasmine.createSpyObj<Template>({method1: 3}, {property1: "4"});
|
||||
|
||||
expect(spyObj.method1()).toEqual(3);
|
||||
expect(spyObj.property1).toEqual("4");
|
||||
});
|
||||
});
|
||||
|
||||
describe('Static Matcher Test', function() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user