type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
() => { tapeSpy = jasmine.createSpyObj<Tape>('tape', ['play', 'pause', 'stop', 'rewind']); tape = tapeSpy; (tape as { isPlaying: boolean }).isPlaying = false; el = jasmine.createSpyObj<Element>('Element', ['hasAttribute']); el.hasAttribute.and.returnValue(false); el.hasAttribute("href"); tape.play(); tape.pause(); tape.rewind(0); tapeSpy.play.and.callThrough(); tapeSpy.pause.and.callThrough(); tapeSpy.rewind.and.callThrough(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(tape.play).toBeDefined(); expect(tape.pause).toBeDefined(); expect(tape.stop).toBeDefined(); expect(tape.rewind).toBeDefined(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(tape.play).toHaveBeenCalled(); expect(tape.pause).toHaveBeenCalled(); expect(tape.rewind).toHaveBeenCalled(); expect(tape.stop).not.toHaveBeenCalled(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(tape.rewind).toHaveBeenCalledWith(0); expect(tape.rewind).toHaveBeenCalledWith('42'); // $ExpectError expect(tape.rewind).toHaveBeenCalledWith(jasmine.anything()); expect(tape.rewind).toHaveBeenCalledWith(jasmine.falsy()); expect(tape.rewind).not.toHaveBeenCalledWith(1); expect(tape.rewind).not.toHaveBeenCalledWith('42'); // $ExpectError expect(tape.rewind).not.toHaveBeenCalledWith(jasmine.truthy()); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(tape.isPlaying).toBe(false); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("spies on all functions", () => { const obj = { x: (a: number) => a, y: (a: number) => a, }; const spy = spyOnAllFunctions(obj); spy.x.and.returnValue(42); spy.y.and.returnValue(24); spy.z; // $ExpectError obj.x(0); obj.y(1); expect(obj.x).toHaveBeenCalled(); expect(obj.y).toHaveBeenCalledWith(1); expect(spy.y).toHaveBeenCalledWith(1); expect(spy.y).toHaveBeenCalledWith("one"); // $ExpectError }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const obj = { x: (a: number) => a, y: (a: number) => a, }; const spy = spyOnAllFunctions(obj); spy.x.and.returnValue(42); spy.y.and.returnValue(24); spy.z; // $ExpectError obj.x(0); obj.y(1); expect(obj.x).toHaveBeenCalled(); expect(obj.y).toHaveBeenCalledWith(1); expect(spy.y).toHaveBeenCalledWith(1); expect(spy.y).toHaveBeenCalledWith("one"); // $ExpectError }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(a: number) => a
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("matches any value", () => { expect().nothing(); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect().nothing(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("matches any value", () => { expect({}).toEqual(jasmine.any(Object)); expect(12).toEqual(jasmine.any(Number)); expect(42).toEqual(jasmine.any(42)); // $ExpectError expect({}).toEqual(jasmine.any({})); // $ExpectError expect(() => null).toEqual(jasmine.any(Function)); }); it("matches any function", () => { interface Test { fn1(): void; fn2(param1: number): number; } const a: Test = { fn1: () => { }, fn2: (param1: number) => param1, }; const expected = { fn1: jasmine.any(Function), fn2: jasmine.any(Function), }; expect(a).toEqual(expected); }); it("matches custom types", () => { class Test { } const obj = new Test(); expect(obj).toEqual(jasmine.any(Test)); }); it("matches base abstract class", () => { abstract class TestClassBase { } class TestClass extends TestClassBase { } const obj = new TestClass(); expect(obj).toEqual(jasmine.any(TestClass)); expect(obj).toEqual(jasmine.any(TestClassBase)); }); it("matches symbols", () => { const sym = Symbol('test symbol'); expect(sym).toEqual(jasmine.any(sym)); }); describe("when used with a spy", () => { it("is useful for comparing arguments", () => { const foo = jasmine.createSpy('foo'); foo(12, () => { return true; }); expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function)); }); it("is useful for comparing arguments for typed spy", () => { const foo = jasmine.createSpy<(num: number, fn: () => boolean) => void>('foo'); foo(12, () => { return true; }); expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function)); }); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect({}).toEqual(jasmine.any(Object)); expect(12).toEqual(jasmine.any(Number)); expect(42).toEqual(jasmine.any(42)); // $ExpectError expect({}).toEqual(jasmine.any({})); // $ExpectError expect(() => null).toEqual(jasmine.any(Function)); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { interface Test { fn1(): void; fn2(param1: number): number; } const a: Test = { fn1: () => { }, fn2: (param1: number) => param1, }; const expected = { fn1: jasmine.any(Function), fn2: jasmine.any(Function), }; expect(a).toEqual(expected); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(param1: number) => param1
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { class Test { } const obj = new Test(); expect(obj).toEqual(jasmine.any(Test)); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { abstract class TestClassBase { } class TestClass extends TestClassBase { } const obj = new TestClass(); expect(obj).toEqual(jasmine.any(TestClass)); expect(obj).toEqual(jasmine.any(TestClassBase)); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const sym = Symbol('test symbol'); expect(sym).toEqual(jasmine.any(sym)); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("is useful for comparing arguments", () => { const foo = jasmine.createSpy('foo'); foo(12, () => { return true; }); expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function)); }); it("is useful for comparing arguments for typed spy", () => { const foo = jasmine.createSpy<(num: number, fn: () => boolean) => void>('foo'); foo(12, () => { return true; }); expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function)); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const foo = jasmine.createSpy('foo'); foo(12, () => { return true; }); expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function)); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { return true; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const foo = jasmine.createSpy<(num: number, fn: () => boolean) => void>('foo'); foo(12, () => { return true; }); expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function)); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(actual: string, customTesters) => { const secondValue = actual.split(',')[1]; return jasmine.matchersUtil.equals(secondValue, 'bar', customTesters); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { interface fooType { a: number; b: number; bar: string; } var foo: fooType; beforeEach(() => { foo = { a: 1, b: 2, bar: "baz" }; }); it("matches objects with the expect key/value pairs", () => { // 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 })); // 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 })); }); it("can be used in a nested object", () => { interface nestedFooType { nested: { a: number; b: number; bar: string; }; } const nestedFoo: nestedFooType = { nested: { a: 1, b: 2, bar: 's', }, }; expect(nestedFoo).toEqual({ nested: jasmine.objectContaining({ b: 2 }) }); }); describe("when used with a spy", () => { it("is useful for comparing arguments", () => { const callback = jasmine.createSpy<(arg: { bar: string }) => number>('callback'); callback.withArgs(jasmine.objectContaining({ bar: "foo" })).and.returnValue(42); callback({ bar: "baz" }); expect(callback).toHaveBeenCalledWith(jasmine.objectContaining({ bar: "baz" })); expect(callback).not.toHaveBeenCalledWith(jasmine.objectContaining({ c: 37 })); }); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { foo = { a: 1, b: 2, bar: "baz" }; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { // 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 })); // 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 })); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { interface nestedFooType { nested: { a: number; b: number; bar: string; }; } const nestedFoo: nestedFooType = { nested: { a: 1, b: 2, bar: 's', }, }; expect(nestedFoo).toEqual({ nested: jasmine.objectContaining({ b: 2 }) }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("is useful for comparing arguments", () => { const callback = jasmine.createSpy<(arg: { bar: string }) => number>('callback'); callback.withArgs(jasmine.objectContaining({ bar: "foo" })).and.returnValue(42); callback({ bar: "baz" }); expect(callback).toHaveBeenCalledWith(jasmine.objectContaining({ bar: "baz" })); expect(callback).not.toHaveBeenCalledWith(jasmine.objectContaining({ c: 37 })); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const callback = jasmine.createSpy<(arg: { bar: string }) => number>('callback'); callback.withArgs(jasmine.objectContaining({ bar: "foo" })).and.returnValue(42); callback({ bar: "baz" }); expect(callback).toHaveBeenCalledWith(jasmine.objectContaining({ bar: "baz" })); expect(callback).not.toHaveBeenCalledWith(jasmine.objectContaining({ c: 37 })); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { var foo: number[]; beforeEach(() => { foo = [1, 2, 3, 4]; }); it("matches arrays with some of the values", () => { expect(foo).toEqual(jasmine.arrayContaining([3, 1])); expect(foo).not.toEqual(jasmine.arrayContaining([6])); expect(foo).toBe(jasmine.arrayContaining([3, 1])); expect(foo).not.toBe(jasmine.arrayContaining([6])); }); it("matches read-only array", () => { const bar: ReadonlyArray<number> = [1, 2, 3, 4]; expect(bar).toEqual(jasmine.arrayContaining([3, 1])); expect(bar).not.toEqual(jasmine.arrayContaining([6])); expect(bar).toBe(jasmine.arrayContaining([3, 1])); }); describe("when used with a spy", () => { it("is useful when comparing arguments", () => { const callback = jasmine.createSpy<(numbers: number[]) => number>('callback'); callback.withArgs(jasmine.arrayContaining([1, 2])).and.returnValue(42); callback([1, 2, 3, 4]); expect(callback).toHaveBeenCalledWith(jasmine.arrayContaining([4, 2, 3])); expect(callback).not.toHaveBeenCalledWith(jasmine.arrayContaining([5, 2])); }); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { foo = [1, 2, 3, 4]; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(foo).toEqual(jasmine.arrayContaining([3, 1])); expect(foo).not.toEqual(jasmine.arrayContaining([6])); expect(foo).toBe(jasmine.arrayContaining([3, 1])); expect(foo).not.toBe(jasmine.arrayContaining([6])); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const bar: ReadonlyArray<number> = [1, 2, 3, 4]; expect(bar).toEqual(jasmine.arrayContaining([3, 1])); expect(bar).not.toEqual(jasmine.arrayContaining([6])); expect(bar).toBe(jasmine.arrayContaining([3, 1])); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("is useful when comparing arguments", () => { const callback = jasmine.createSpy<(numbers: number[]) => number>('callback'); callback.withArgs(jasmine.arrayContaining([1, 2])).and.returnValue(42); callback([1, 2, 3, 4]); expect(callback).toHaveBeenCalledWith(jasmine.arrayContaining([4, 2, 3])); expect(callback).not.toHaveBeenCalledWith(jasmine.arrayContaining([5, 2])); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const callback = jasmine.createSpy<(numbers: number[]) => number>('callback'); callback.withArgs(jasmine.arrayContaining([1, 2])).and.returnValue(42); callback([1, 2, 3, 4]); expect(callback).toHaveBeenCalledWith(jasmine.arrayContaining([4, 2, 3])); expect(callback).not.toHaveBeenCalledWith(jasmine.arrayContaining([5, 2])); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { var foo: number[]; beforeEach(() => { foo = [1, 2, 3, 4]; }); it("matches arrays with exactly the same values", () => { expect(foo).toEqual(jasmine.arrayWithExactContents([1, 2, 3, 4])); expect(foo).not.toEqual(jasmine.arrayWithExactContents([6])); expect(foo).toBe(jasmine.arrayWithExactContents([1, 2, 3, 4])); expect(foo).not.toBe(jasmine.arrayWithExactContents([6])); }); describe("when used with a spy", () => { it("is useful when comparing arguments", () => { const callback = jasmine.createSpy<(arg: number[]) => number>('callback'); callback.withArgs(jasmine.arrayWithExactContents([1, 2])).and.returnValue(42); callback([1, 2, 3, 4]); expect(callback).toHaveBeenCalledWith(jasmine.arrayWithExactContents([1, 2, 3, 4])); expect(callback).not.toHaveBeenCalledWith(jasmine.arrayWithExactContents([5, 2])); }); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(foo).toEqual(jasmine.arrayWithExactContents([1, 2, 3, 4])); expect(foo).not.toEqual(jasmine.arrayWithExactContents([6])); expect(foo).toBe(jasmine.arrayWithExactContents([1, 2, 3, 4])); expect(foo).not.toBe(jasmine.arrayWithExactContents([6])); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("is useful when comparing arguments", () => { const callback = jasmine.createSpy<(arg: number[]) => number>('callback'); callback.withArgs(jasmine.arrayWithExactContents([1, 2])).and.returnValue(42); callback([1, 2, 3, 4]); expect(callback).toHaveBeenCalledWith(jasmine.arrayWithExactContents([1, 2, 3, 4])); expect(callback).not.toHaveBeenCalledWith(jasmine.arrayWithExactContents([5, 2])); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const callback = jasmine.createSpy<(arg: number[]) => number>('callback'); callback.withArgs(jasmine.arrayWithExactContents([1, 2])).and.returnValue(42); callback([1, 2, 3, 4]); expect(callback).toHaveBeenCalledWith(jasmine.arrayWithExactContents([1, 2, 3, 4])); expect(callback).not.toHaveBeenCalledWith(jasmine.arrayWithExactContents([5, 2])); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { var timerCallback: any; beforeEach(() => { timerCallback = jasmine.createSpy("timerCallback"); jasmine.clock().install(); }); afterEach(() => { jasmine.clock().uninstall(); }); it("causes a timeout to be called synchronously", () => { setTimeout(() => { timerCallback(); }, 100); expect(timerCallback).not.toHaveBeenCalled(); jasmine.clock().tick(101); expect(timerCallback).toHaveBeenCalled(); }); it("causes an interval to be called synchronously", () => { setInterval(() => { timerCallback(); }, 100); expect(timerCallback).not.toHaveBeenCalled(); jasmine.clock().tick(101); expect(timerCallback.calls.count()).toEqual(1); jasmine.clock().tick(50); expect(timerCallback.calls.count()).toEqual(1); jasmine.clock().tick(50); expect(timerCallback.calls.count()).toEqual(2); }); describe("Mocking the Date object", () => { it("mocks the Date object and sets it to a given time", () => { const baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); jasmine.clock().tick(50); expect(new Date().getTime()).toEqual(baseTime.getTime() + 50); }); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { timerCallback = jasmine.createSpy("timerCallback"); jasmine.clock().install(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { jasmine.clock().uninstall(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { setTimeout(() => { timerCallback(); }, 100); expect(timerCallback).not.toHaveBeenCalled(); jasmine.clock().tick(101); expect(timerCallback).toHaveBeenCalled(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { timerCallback(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { setInterval(() => { timerCallback(); }, 100); expect(timerCallback).not.toHaveBeenCalled(); jasmine.clock().tick(101); expect(timerCallback.calls.count()).toEqual(1); jasmine.clock().tick(50); expect(timerCallback.calls.count()).toEqual(1); jasmine.clock().tick(50); expect(timerCallback.calls.count()).toEqual(2); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("mocks the Date object and sets it to a given time", () => { const baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); jasmine.clock().tick(50); expect(new Date().getTime()).toEqual(baseTime.getTime() + 50); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); jasmine.clock().tick(50); expect(new Date().getTime()).toEqual(baseTime.getTime() + 50); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { var value: number; beforeEach((done: DoneFn) => { setTimeout(() => { value = 0; done(); }, 1); }); it("should support async execution of test preparation and expectations", (done: DoneFn) => { value += 1; expect(value).toBeGreaterThan(0); done(); }); describe("long asynchronous specs", () => { beforeEach((done: DoneFn) => { done(); }, 1000); it("takes a long time", (done: DoneFn) => { setTimeout(() => { done(); }, 9000); }, 10000); afterEach((done: DoneFn) => { done(); }, 1000); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(done: DoneFn) => { setTimeout(() => { value = 0; done(); }, 1); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { value = 0; done(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(done: DoneFn) => { value += 1; expect(value).toBeGreaterThan(0); done(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { beforeEach((done: DoneFn) => { done(); }, 1000); it("takes a long time", (done: DoneFn) => { setTimeout(() => { done(); }, 9000); }, 10000); afterEach((done: DoneFn) => { done(); }, 1000); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(done: DoneFn) => { done(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(done: DoneFn) => { setTimeout(() => { done(); }, 9000); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { done(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("should fail test when called without arguments", () => { fail(); }); it("should fail test when called with a fail message", () => { fail("The test failed"); }); it("should fail test when called an error", () => { fail(new Error("The test failed with this error")); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { fail(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { fail("The test failed"); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { fail(new Error("The test failed with this error")); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const myCustomEquality: jasmine.CustomEqualityTester = function(first: any, second: any): boolean | void { if (typeof first === "string" && typeof second === "string") { return first[0] === second[1]; } }; beforeEach(() => { jasmine.addCustomEqualityTester(myCustomEquality); }); it("should be custom equal", () => { expect("abc").toEqual("aaa"); }); it("should be custom not equal", () => { expect("abc").not.toEqual("abc"); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { jasmine.addCustomEqualityTester(myCustomEquality); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect("abc").toEqual("aaa"); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect("abc").not.toEqual("abc"); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(util: jasmine.MatchersUtil, customEqualityTesters: jasmine.CustomEqualityTester[]) => { return { compare: (actual: any, expected: any): jasmine.CustomMatcherResult => { if (expected === undefined) { expected = ''; } const result: jasmine.CustomMatcherResult = { pass: false }; result.pass = util.equals(actual.hyuk, "gawrsh" + expected, customEqualityTesters); result.message = result.pass ? `Expected ${actual} not to be quite so goofy` : `Expected ${actual} to be goofy, but it was not very goofy`; return result; } }; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(actual: any, expected: any): jasmine.CustomMatcherResult => { if (expected === undefined) { expected = ''; } const result: jasmine.CustomMatcherResult = { pass: false }; result.pass = util.equals(actual.hyuk, "gawrsh" + expected, customEqualityTesters); result.message = result.pass ? `Expected ${actual} not to be quite so goofy` : `Expected ${actual} to be goofy, but it was not very goofy`; return result; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(util: jasmine.MatchersUtil, customEqualityTesters: jasmine.CustomEqualityTester[]) => { return { compare: (actual: any, floor: number, ceiling: number): jasmine.CustomMatcherResult => { const pass = actual >= floor && actual <= ceiling; const message = `expected ${actual} to be within range ${floor}-${ceiling}`; return { message, pass }; }, negativeCompare: (actual: any, floor: number, ceiling: number): jasmine.CustomMatcherResult => { const pass = actual < floor && actual > ceiling; const message = `expected ${actual} not to be within range ${floor}-${ceiling}`; return { message, pass }; } }; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(actual: any, floor: number, ceiling: number): jasmine.CustomMatcherResult => { const pass = actual >= floor && actual <= ceiling; const message = `expected ${actual} to be within range ${floor}-${ceiling}`; return { message, pass }; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(actual: any, floor: number, ceiling: number): jasmine.CustomMatcherResult => { const pass = actual < floor && actual > ceiling; const message = `expected ${actual} not to be within range ${floor}-${ceiling}`; return { message, pass }; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { beforeEach(() => { jasmine.addMatchers(customMatchers); }); it("is available on an expectation", () => { expect({ hyuk: 'gawrsh' }).toBeGoofy(); }); it("can take an 'expected' parameter", () => { expect({ hyuk: 'gawrsh is fun' }).toBeGoofy({ hyuk: ' is fun' }); }); it("can take many 'expected' parameters", () => { expect(2).toBeWithinRange(1, 3); }); it("can use the custom negativeCompare method", () => { const matcher = customMatchers["toBeWithinRange"](jasmine.matchersUtil, []); const result = matcher.negativeCompare!(1, 2, 3); expect(result.pass).toBe(false); expect(result.message).toBe("expected 1 not to be within range 2-3"); }); it("can be negated", () => { expect({ hyuk: 'this is fun' }).not.toBeGoofy(); }); it("has a proper message on failure", () => { const actual = { hyuk: 'this is fun' }; const matcher = customMatchers["toBeGoofy"](jasmine.matchersUtil, []); const result = matcher.compare(actual, null); expect(result.pass).toBe(false); expect(result.message).toBe(`Expected ${actual} to be goofy, but it was not very goofy`); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { jasmine.addMatchers(customMatchers); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect({ hyuk: 'gawrsh' }).toBeGoofy(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect({ hyuk: 'gawrsh is fun' }).toBeGoofy({ hyuk: ' is fun' }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(2).toBeWithinRange(1, 3); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const matcher = customMatchers["toBeWithinRange"](jasmine.matchersUtil, []); const result = matcher.negativeCompare!(1, 2, 3); expect(result.pass).toBe(false); expect(result.message).toBe("expected 1 not to be within range 2-3"); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect({ hyuk: 'this is fun' }).not.toBeGoofy(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const actual = { hyuk: 'this is fun' }; const matcher = customMatchers["toBeGoofy"](jasmine.matchersUtil, []); const result = matcher.compare(actual, null); expect(result.pass).toBe(false); expect(result.message).toBe(`Expected ${actual} to be goofy, but it was not very goofy`); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { describe('a typed spy', () => { const spy = jasmine.createSpy('spy', (num: number, str: string) => { return `${num} and ${str}`; }); it('has a typed returnValue', () => { // $ExpectType (val: string) => Spy<(num: number, str: string) => string> spy.and.returnValue; }); it('has a typed calls property', () => { spy.calls.first().args; // $ExpectType [number, string] spy.calls.first().returnValue; // $ExpectType string }); it('has a typed callFake', () => { // $ExpectType (fn: (num: number, str: string) => string) => Spy<(num: number, str: string) => string> spy.and.callFake; }); }); describe('spyOn', () => { it('only works on methods', () => { const foo = { method() { return 'baz'; }, value: 'value', }; const spy = spyOn(foo, 'method'); const spy2 = spyOn(foo, 'value'); // $ExpectError // $ExpectType string spy.calls.first().returnValue; }); it('works on constructors', () => { class MyClass { constructor(readonly foo: string) { } } const namespace = { MyClass }; const spy = spyOn(namespace, 'MyClass'); spy.and.returnValue({ foo: 'test' }); spy.and.returnValue({}); // $ExpectError spy.and.returnValue({ foo: 123 }); // $ExpectError }); it('can allows overriding the generic', () => { class Base { service() { } } class Super extends Base { service2() { } } spyOn<Base>(new Super(), 'service'); spyOn<Base>(new Super(), 'service2'); // $ExpectError }); }); describe('createSpyObj', () => { it('returns the correct spy types', () => { const foo = { method() { return 'baz'; }, value: 'value', }; const spyObj = jasmine.createSpyObj<typeof foo>('foo', ['method']); // $ExpectType (val: string) => Spy<() => string> spyObj.method.and.returnValue; }); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const spy = jasmine.createSpy('spy', (num: number, str: string) => { return `${num} and ${str}`; }); it('has a typed returnValue', () => { // $ExpectType (val: string) => Spy<(num: number, str: string) => string> spy.and.returnValue; }); it('has a typed calls property', () => { spy.calls.first().args; // $ExpectType [number, string] spy.calls.first().returnValue; // $ExpectType string }); it('has a typed callFake', () => { // $ExpectType (fn: (num: number, str: string) => string) => Spy<(num: number, str: string) => string> spy.and.callFake; }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(num: number, str: string) => { return `${num} and ${str}`; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { // $ExpectType (val: string) => Spy<(num: number, str: string) => string> spy.and.returnValue; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { spy.calls.first().args; // $ExpectType [number, string] spy.calls.first().returnValue; // $ExpectType string }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { // $ExpectType (fn: (num: number, str: string) => string) => Spy<(num: number, str: string) => string> spy.and.callFake; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it('only works on methods', () => { const foo = { method() { return 'baz'; }, value: 'value', }; const spy = spyOn(foo, 'method'); const spy2 = spyOn(foo, 'value'); // $ExpectError // $ExpectType string spy.calls.first().returnValue; }); it('works on constructors', () => { class MyClass { constructor(readonly foo: string) { } } const namespace = { MyClass }; const spy = spyOn(namespace, 'MyClass'); spy.and.returnValue({ foo: 'test' }); spy.and.returnValue({}); // $ExpectError spy.and.returnValue({ foo: 123 }); // $ExpectError }); it('can allows overriding the generic', () => { class Base { service() { } } class Super extends Base { service2() { } } spyOn<Base>(new Super(), 'service'); spyOn<Base>(new Super(), 'service2'); // $ExpectError }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const foo = { method() { return 'baz'; }, value: 'value', }; const spy = spyOn(foo, 'method'); const spy2 = spyOn(foo, 'value'); // $ExpectError // $ExpectType string spy.calls.first().returnValue; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { class MyClass { constructor(readonly foo: string) { } } const namespace = { MyClass }; const spy = spyOn(namespace, 'MyClass'); spy.and.returnValue({ foo: 'test' }); spy.and.returnValue({}); // $ExpectError spy.and.returnValue({ foo: 123 }); // $ExpectError }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { class Base { service() { } } class Super extends Base { service2() { } } spyOn<Base>(new Super(), 'service'); spyOn<Base>(new Super(), 'service2'); // $ExpectError }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it('returns the correct spy types', () => { const foo = { method() { return 'baz'; }, value: 'value', }; const spyObj = jasmine.createSpyObj<typeof foo>('foo', ['method']); // $ExpectType (val: string) => Spy<() => string> spyObj.method.and.returnValue; }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const foo = { method() { return 'baz'; }, value: 'value', }; const spyObj = jasmine.createSpyObj<typeof foo>('foo', ['method']); // $ExpectType (val: string) => Spy<() => string> spyObj.method.and.returnValue; }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(suiteInfo: jasmine.SuiteInfo) => { console.log("Running suite with " + suiteInfo.totalSpecsDefined); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(result: jasmine.CustomReporterResult) => { console.log(`Suite started: ${result.description} whose full description is: ${result.fullName}`); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(result: jasmine.CustomReporterResult) => { console.log(`Spec started: ${result.description} whose full description is: ${result.fullName}`); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(result: jasmine.CustomReporterResult) => { console.log(`Spec: ${result.description} was ${result.status}`); // tslint:disable-next-line:prefer-for-of for (var i = 0; result.failedExpectations && i < result.failedExpectations.length; i += 1) { console.log("Failure: " + result.failedExpectations[i].message); console.log("Actual: " + result.failedExpectations[i].actual); console.log("Expected: " + result.failedExpectations[i].expected); console.log(result.failedExpectations[i].stack); } console.log(result.passedExpectations && result.passedExpectations.length); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(result: jasmine.CustomReporterResult) => { console.log(`Suite: ${result.description} was ${result.status}`); // tslint:disable-next-line:prefer-for-of for (var i = 0; result.failedExpectations && i < result.failedExpectations.length; i += 1) { console.log('AfterAll ' + result.failedExpectations[i].message); console.log(result.failedExpectations[i].stack); } }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
(runDetails: jasmine.RunDetails) => { console.log('Finished suite'); console.log('Random:', runDetails.order.random); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { it("should allow randomization of the order of tests", () => { expect(() => { const env = jasmine.getEnv(); env.configure({ random: true }); }).not.toThrow(); }); it("should allow a seed to be passed in for randomization", () => { expect(() => { const env = jasmine.getEnv(); env.configure({ random: true, seed: 1234 }); }).not.toThrow(); }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(() => { const env = jasmine.getEnv(); env.configure({ random: true }); }).not.toThrow(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const env = jasmine.getEnv(); env.configure({ random: true }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect(() => { const env = jasmine.getEnv(); env.configure({ random: true, seed: 1234 }); }).not.toThrow(); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { const env = jasmine.getEnv(); env.configure({ random: true, seed: 1234 }); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect({ value: null }).toEqual( jasmine.objectContaining({ value: jasmine.falsy(), }) ); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript
ArrowFunction
() => { expect({ value: null }).toEqual( jasmine.objectContaining({ value: jasmine.truthy(), }) ); }
Bat-Orshikh/DefinitelyTyped
types/jasmine/ts3.1/jasmine-tests.ts
TypeScript