mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-05 09:40:02 +00:00
Make createSpyObj definitions consistent - same strict type for all methodNames arguments. (#25466)
This commit is contained in:
10
types/jasmine/index.d.ts
vendored
10
types/jasmine/index.d.ts
vendored
@@ -130,6 +130,7 @@ declare function waits(timeout?: number): void;
|
||||
|
||||
declare namespace jasmine {
|
||||
type Expected<T> = T | ObjectContaining<T> | Any | Spy;
|
||||
type SpyObjMethodNames = string[] | {[methodName: string]: any};
|
||||
|
||||
var clock: () => Clock;
|
||||
|
||||
@@ -144,12 +145,11 @@ declare namespace jasmine {
|
||||
function objectContaining<T>(sample: Partial<T>): ObjectContaining<T>;
|
||||
function createSpy(name?: string, originalFn?: Function): Spy;
|
||||
|
||||
function createSpyObj(baseName: string, methodNames: any[] | {[methodName: string]: any}): any;
|
||||
function createSpyObj<T>(baseName: string, methodNames: any[] | {[methodName: string]: any}): SpyObj<T>;
|
||||
function createSpyObj(baseName: string, methodNames: SpyObjMethodNames): any;
|
||||
function createSpyObj<T>(baseName: string, methodNames: SpyObjMethodNames): SpyObj<T>;
|
||||
|
||||
function createSpyObj(baseName: string, methodNames: any): any;
|
||||
function createSpyObj(methodNames: any[]): any;
|
||||
function createSpyObj(methodNames: any): any;
|
||||
function createSpyObj(methodNames: SpyObjMethodNames): any;
|
||||
function createSpyObj<T>(methodNames: SpyObjMethodNames): SpyObj<T>;
|
||||
|
||||
function pp(value: any): string;
|
||||
|
||||
|
||||
@@ -1109,7 +1109,17 @@ describe("createSpyObj", function () {
|
||||
expect(spyObj.method2.and.identity()).toEqual('BaseName.method2');
|
||||
});
|
||||
|
||||
it("should allow you to omit the baseName", function () {
|
||||
it("should allow you to omit the baseName and takes only an object", function () {
|
||||
var spyObj = jasmine.createSpyObj({ 'method1': 42, 'method2': 'special sauce' });
|
||||
|
||||
expect(spyObj.method1()).toEqual(42);
|
||||
expect(spyObj.method1.and.identity()).toEqual('unknown.method1');
|
||||
|
||||
expect(spyObj.method2()).toEqual('special sauce');
|
||||
expect(spyObj.method2.and.identity()).toEqual('unknown.method2');
|
||||
});
|
||||
|
||||
it("should allow you to omit the baseName and takes only a list of methods", function () {
|
||||
var spyObj = jasmine.createSpyObj(['method1', 'method2']);
|
||||
|
||||
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function) });
|
||||
@@ -1117,12 +1127,6 @@ describe("createSpyObj", function () {
|
||||
expect(spyObj.method2.and.identity()).toEqual('unknown.method2');
|
||||
});
|
||||
|
||||
it("should throw if you do not pass an array or object argument", function () {
|
||||
expect(function () {
|
||||
jasmine.createSpyObj('BaseName');
|
||||
}).toThrow("createSpyObj requires a non-empty array or object of method names to create spies for");
|
||||
});
|
||||
|
||||
it("should throw if you pass an empty array argument", function () {
|
||||
expect(function () {
|
||||
jasmine.createSpyObj('BaseName', []);
|
||||
|
||||
Reference in New Issue
Block a user