mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
committed by
Mohamed Hegazy
parent
3b1ba96df2
commit
470a4e1eaa
10
types/jasmine/index.d.ts
vendored
10
types/jasmine/index.d.ts
vendored
@@ -34,7 +34,7 @@ interface DoneFn extends Function {
|
||||
(): void;
|
||||
|
||||
/** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */
|
||||
fail: (message?: Error|string) => void;
|
||||
fail: (message?: Error | string) => void;
|
||||
}
|
||||
|
||||
declare function spyOn<T>(object: T, method: keyof T): jasmine.Spy;
|
||||
@@ -61,6 +61,10 @@ declare namespace jasmine {
|
||||
function createSpyObj(baseName: string, methodNames: any[]): any;
|
||||
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
|
||||
|
||||
function createSpyObj(baseName: string, methodNames: any): any;
|
||||
function createSpyObj(methodNames: any[]): any;
|
||||
function createSpyObj(methodNames: any): any;
|
||||
|
||||
function pp(value: any): string;
|
||||
|
||||
function getEnv(): Env;
|
||||
@@ -248,7 +252,7 @@ declare namespace jasmine {
|
||||
}
|
||||
|
||||
interface Order {
|
||||
new (options: {random: boolean, seed: string}): any;
|
||||
new (options: { random: boolean, seed: string }): any;
|
||||
random: boolean;
|
||||
seed: string;
|
||||
sort<T>(items: T[]): T[];
|
||||
@@ -510,7 +514,7 @@ declare namespace jasmine {
|
||||
identity: string;
|
||||
and: SpyAnd;
|
||||
calls: Calls;
|
||||
mostRecentCall: {args: any[]; };
|
||||
mostRecentCall: { args: any[]; };
|
||||
argsForCall: any[];
|
||||
}
|
||||
|
||||
|
||||
@@ -841,7 +841,7 @@ describe("Fail", () => {
|
||||
|
||||
// test based on http://jasmine.github.io/2.2/custom_equality.html
|
||||
describe("custom equality", () => {
|
||||
var myCustomEquality: jasmine.CustomEqualityTester = function(first: any, second: any): boolean {
|
||||
var myCustomEquality: jasmine.CustomEqualityTester = function (first: any, second: any): boolean {
|
||||
if (typeof first === "string" && typeof second === "string") {
|
||||
return first[0] === second[1];
|
||||
}
|
||||
@@ -983,6 +983,54 @@ 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 () {
|
||||
var spyObj = jasmine.createSpyObj('BaseName', { 'method1': 42, 'method2': 'special sauce' });
|
||||
|
||||
expect(spyObj.method1()).toEqual(42);
|
||||
expect(spyObj.method1.and.identity()).toEqual('BaseName.method1');
|
||||
|
||||
expect(spyObj.method2()).toEqual('special sauce');
|
||||
expect(spyObj.method2.and.identity()).toEqual('BaseName.method2');
|
||||
});
|
||||
|
||||
|
||||
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function () {
|
||||
var spyObj = jasmine.createSpyObj('BaseName', ['method1', 'method2']);
|
||||
|
||||
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function) });
|
||||
expect(spyObj.method1.and.identity()).toEqual('BaseName.method1');
|
||||
expect(spyObj.method2.and.identity()).toEqual('BaseName.method2');
|
||||
});
|
||||
|
||||
it("should allow you to omit the baseName", function () {
|
||||
var spyObj = jasmine.createSpyObj(['method1', 'method2']);
|
||||
|
||||
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function) });
|
||||
expect(spyObj.method1.and.identity()).toEqual('unknown.method1');
|
||||
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', []);
|
||||
}).toThrow("createSpyObj requires a non-empty array or object of method names to create spies for");
|
||||
});
|
||||
|
||||
it("should throw if you pass an empty object argument", function () {
|
||||
expect(function () {
|
||||
jasmine.createSpyObj('BaseName', {});
|
||||
}).toThrow("createSpyObj requires a non-empty array or object of method names to create spies for");
|
||||
});
|
||||
});
|
||||
|
||||
(() => {
|
||||
// from boot.js
|
||||
var env = jasmine.getEnv();
|
||||
|
||||
Reference in New Issue
Block a user