type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
|---|---|---|---|---|
ArrowFunction
|
() => {
const foo = () => {
throw new TypeError("foo bar baz");
};
expect(foo).toThrowError("foo bar baz");
expect(foo).toThrowError(/bar/);
expect(foo).toThrowError(TypeError);
expect(foo).toThrowError(TypeError, "foo bar baz");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
throw new TypeError("foo bar baz");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
class MyClass { }
expect(new MyClass()).toBeInstanceOf(MyClass);
expect('foo').toBeInstanceOf(String);
expect(3).toBeInstanceOf(Number);
expect(new Error()).toBeInstanceOf(Error);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
async () => {
const badness = new Error("badness");
await expectAsync(Promise.resolve()).toBeResolved();
await expectAsync(Promise.resolve()).toBeResolved("good job");
await expectAsync(Promise.resolve(true)).toBeResolvedTo(true);
await expectAsync(Promise.reject(badness)).toBeRejected();
await expectAsync(Promise.reject(badness)).toBeRejected("bad mojo");
await expectAsync(Promise.reject(badness)).toBeRejectedWith(badness);
await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error, "badness");
await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error, /badness/);
await expectAsync(Promise.reject(badness)).toBeRejectedWithError(Error);
await expectAsync(Promise.reject(badness)).toBeRejectedWithError("badness");
await expectAsync(Promise.reject(badness)).toBeRejectedWithError(/badness/);
await expectAsync(Promise.resolve()).withContext("additional info").toBeResolved();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
async () => {
const badness = new Error("badness");
const malady = new Error("malady");
await expectAsync(Promise.reject(badness)).not.toBeResolved();
await expectAsync(Promise.resolve(true)).not.toBeResolvedTo(false);
await expectAsync(Promise.resolve()).not.toBeRejected();
await expectAsync(Promise.reject(badness)).not.toBeRejectedWith(malady);
await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(Error, "malady");
await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(Error, /malady/);
await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError("malady");
await expectAsync(Promise.reject(badness)).not.toBeRejectedWithError(/malady/);
await expectAsync(Promise.reject(badness)).not.withContext("additional info").toBeResolved();
await expectAsync(Promise.reject(badness)).withContext("additional info").not.toBeResolved();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(() => {
({} as any).doSomething();
}).toThrowMatching(error => error !== undefined);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
({} as any).doSomething();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
error => error !== undefined
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect("").toBeNegativeInfinity();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect("").toBePositiveInfinity();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
const element: HTMLElement = null!;
expect(element).toHaveClass("some-class");
expect(element).toHaveClass(Element); // $ExpectError
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
it("is just a function, so it can contain any code", () => {
var foo = 0;
foo += 1;
expect(foo).toEqual(1);
});
it("can have more than one expectation", () => {
var foo = 0;
foo += 1;
expect(foo).toEqual(1);
expect(true).toEqual(true);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo = 0;
foo += 1;
expect(foo).toEqual(1);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo = 0;
foo += 1;
expect(foo).toEqual(1);
expect(true).toEqual(true);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: number;
beforeEach(() => {
foo = 0;
foo += 1;
});
afterEach(() => {
foo = 0;
});
it("is just a function, so it can contain any code", () => {
expect(foo).toEqual(1);
});
it("can have more than one expectation", () => {
expect(foo).toEqual(1);
expect(true).toEqual(true);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = 0;
foo += 1;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = 0;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo).toEqual(1);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo).toEqual(1);
expect(true).toEqual(true);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: number;
beforeEach(() => {
foo = 0;
foo += 1;
});
afterEach(() => {
foo = 0;
});
it("is just a function, so it can contain any code", () => {
expect(foo).toEqual(1);
});
it("can have more than one expectation", () => {
expect(foo).toEqual(1);
expect(true).toEqual(true);
});
describe("nested inside a second describe", () => {
var bar: number;
beforeEach(() => {
bar = 1;
});
it("can reference both scopes as needed", () => {
expect(foo).toEqual(bar);
});
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var bar: number;
beforeEach(() => {
bar = 1;
});
it("can reference both scopes as needed", () => {
expect(foo).toEqual(bar);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
bar = 1;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo).toEqual(bar);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
it("can be used after an expectation", () => {
expect(1).withContext('context message').toBe(1);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(1).withContext('context message').toBe(1);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: number;
beforeEach(() => {
foo = 0;
foo += 1;
});
it("is just a function, so it can contain any code", () => {
expect(foo).toEqual(1);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
xit("can be declared 'xit'", () => {
expect(true).toBe(false);
});
it("can be declared with 'it' but without a function");
it("can be declared by calling 'pending' in the spec body", () => {
expect(true).toBe(false);
pending(); // without reason
pending('this is why it is pending');
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(true).toBe(false);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(true).toBe(false);
pending(); // without reason
pending('this is why it is pending');
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any, baz: any = null;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
},
setBaz: (value: any) => {
baz = value;
}
};
spyOn(foo, 'setBar');
spyOn(foo, 'setBaz');
foo.setBar(123);
foo.setBar(456, 'another param');
foo.setBaz(789);
});
it("tracks that the spy was called", () => {
expect(foo.setBar).toHaveBeenCalled();
});
it("tracks all the arguments of its calls", () => {
expect(foo.setBar).toHaveBeenCalledWith(123);
expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');
});
it("tracks the order in which spies were called", () => {
expect(foo.setBar).toHaveBeenCalledBefore(foo.setBaz);
});
it("stops all execution on a function", () => {
expect(bar).toBeNull();
});
it("tracks if it was called at all", function() {
foo.setBar();
expect(foo.setBar.calls.any()).toEqual(true);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
},
setBaz: (value: any) => {
baz = value;
}
};
spyOn(foo, 'setBar');
spyOn(foo, 'setBaz');
foo.setBar(123);
foo.setBar(456, 'another param');
foo.setBaz(789);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
(value: any) => {
bar = value;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
(value: any) => {
baz = value;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo.setBar).toHaveBeenCalled();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo.setBar).toHaveBeenCalledWith(123);
expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo.setBar).toHaveBeenCalledBefore(foo.setBaz);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(bar).toBeNull();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any, fetchedBar: any;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, 'getBar').and.callThrough();
foo.setBar(123);
fetchedBar = foo.getBar();
});
it("tracks that the spy was called", () => {
expect(foo.getBar).toHaveBeenCalled();
});
it("should not effect other functions", () => {
expect(bar).toEqual(123);
});
it("when called returns the requested value", () => {
expect(fetchedBar).toEqual(123);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, 'getBar').and.callThrough();
foo.setBar(123);
fetchedBar = foo.getBar();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
return bar;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo.getBar).toHaveBeenCalled();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(bar).toEqual(123);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(fetchedBar).toEqual(123);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var bar: number;
const foo = {
setBar: (value: number) => {
bar = value;
},
getBar: () => {
return bar;
}
};
it("verifies return value type", () => {
spyOn(foo, "getBar").and.returnValue(745);
spyOn(foo, "getBar").and.returnValue("42"); // $ExpectError
});
it("tracks that the spy was called", () => {
expect(foo.getBar).toHaveBeenCalled();
});
it("should not effect other functions", () => {
expect(bar).toEqual(123);
});
it("when called returns the requested value", () => {
const fetchedBar = foo.getBar();
expect(fetchedBar).toEqual(745);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
(value: number) => {
bar = value;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
return bar;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
spyOn(foo, "getBar").and.returnValue(745);
spyOn(foo, "getBar").and.returnValue("42"); // $ExpectError
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
const fetchedBar = foo.getBar();
expect(fetchedBar).toEqual(745);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, "getBar").and.returnValues("fetched first", "fetched second");
foo.setBar(123);
});
it("tracks that the spy was called", () => {
foo.getBar(123);
expect(foo.getBar).toHaveBeenCalled();
});
it("should not affect other functions", () => {
expect(bar).toEqual(123);
});
it("when called multiple times returns the requested values in order", () => {
expect(foo.getBar()).toEqual("fetched first");
expect(foo.getBar()).toEqual("fetched second");
expect(foo.getBar()).toBeUndefined();
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, "getBar").and.returnValues("fetched first", "fetched second");
foo.setBar(123);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.getBar(123);
expect(foo.getBar).toHaveBeenCalled();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo.getBar()).toEqual("fetched first");
expect(foo.getBar()).toEqual("fetched second");
expect(foo.getBar()).toBeUndefined();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
const bar = 10;
const foo = {
getAsyncBar: () => {
return Promise.resolve(bar);
}
};
it("verifies return value type", () => {
spyOn(foo, "getAsyncBar").and.resolveTo(745);
spyOn(foo, "getAsyncBar").and.resolveTo("42"); // $ExpectError
});
it("tracks that the spy was called", async () => {
await foo.getAsyncBar();
expect(foo.getAsyncBar).toHaveBeenCalled();
});
it("when called returns the requested value", async () => {
spyOn(foo, "getAsyncBar").and.resolveTo(745);
await expectAsync(foo.getAsyncBar()).toBeResolvedTo(745);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
return Promise.resolve(bar);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
spyOn(foo, "getAsyncBar").and.resolveTo(745);
spyOn(foo, "getAsyncBar").and.resolveTo("42"); // $ExpectError
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
async () => {
await foo.getAsyncBar();
expect(foo.getAsyncBar).toHaveBeenCalled();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
async () => {
spyOn(foo, "getAsyncBar").and.resolveTo(745);
await expectAsync(foo.getAsyncBar()).toBeResolvedTo(745);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
const bar = 10;
const foo = {
getAsyncBar: () => {
return Promise.resolve(bar);
},
getBar: () => {
return bar;
}
};
it("verifies rejection value type", () => {
spyOn(foo, "getAsyncBar").and.rejectWith("Error message");
spyOn(foo, "getBar").and.rejectWith("42"); // $ExpectError
});
it("when called, it is rejected with the requested value", async () => {
spyOn(foo, "getAsyncBar").and.rejectWith("Error message");
await expectAsync(foo.getAsyncBar()).toBeRejectedWith("Error message");
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
spyOn(foo, "getAsyncBar").and.rejectWith("Error message");
spyOn(foo, "getBar").and.rejectWith("42"); // $ExpectError
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
async () => {
spyOn(foo, "getAsyncBar").and.rejectWith("Error message");
await expectAsync(foo.getAsyncBar()).toBeRejectedWith("Error message");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any, fetchedBar: any;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, "getBar").and.callFake(() => {
return 1001;
});
foo.setBar(123);
fetchedBar = foo.getBar();
});
it("tracks that the spy was called", () => {
expect(foo.getBar).toHaveBeenCalled();
});
it("should not effect other functions", () => {
expect(bar).toEqual(123);
});
it("when called returns the requested value", () => {
expect(fetchedBar).toEqual(1001);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, "getBar").and.callFake(() => {
return 1001;
});
foo.setBar(123);
fetchedBar = foo.getBar();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
return 1001;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(fetchedBar).toEqual(1001);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any, fetchedBar: any;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, "getBar")
.withArgs(1, "2")
.and.callFake(() => 1002);
foo.setBar(123);
fetchedBar = foo.getBar(1, "2");
});
it("tracks that the spy was called", () => {
expect(foo.getBar).toHaveBeenCalled();
});
it("should not effect other functions", () => {
expect(bar).toEqual(123);
});
it("when called returns the requested value", () => {
expect(fetchedBar).toEqual(1002);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, "getBar")
.withArgs(1, "2")
.and.callFake(() => 1002);
foo.setBar(123);
fetchedBar = foo.getBar(1, "2");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => 1002
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(fetchedBar).toEqual(1002);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
}
};
spyOn(foo, "setBar").and.throwError("quux");
});
it("throws the value", () => {
expect(() => {
foo.setBar(123);
}).toThrowError("quux");
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
}
};
spyOn(foo, "setBar").and.throwError("quux");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(() => {
foo.setBar(123);
}).toThrowError("quux");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.setBar(123);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any, fetchedBar: any;
var fakeCalled = false;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, 'getBar').and.callThrough().and.callFake(() => {
fakeCalled = true;
});
foo.setBar(123);
fetchedBar = foo.getBar();
});
it("tracks that the spy was called", () => {
expect(foo.getBar).toHaveBeenCalled();
});
it("should not effect other functions", () => {
expect(bar).toEqual(123);
});
it("when called returns the requested value", () => {
expect(fetchedBar).toEqual(123);
});
it("should have called the fake implementation", () => {
expect(fakeCalled).toEqual(true);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
},
getBar: () => {
return bar;
}
};
spyOn(foo, 'getBar').and.callThrough().and.callFake(() => {
fakeCalled = true;
});
foo.setBar(123);
fetchedBar = foo.getBar();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
fakeCalled = true;
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(fakeCalled).toEqual(true);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any = null;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
}
};
spyOn(foo, 'setBar').and.callThrough();
});
it("can call through and then stub in the same spec", () => {
foo.setBar(123);
expect(bar).toEqual(123);
foo.setBar.and.stub();
bar = null;
foo.setBar(123);
expect(bar).toBe(null);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
}
};
spyOn(foo, 'setBar').and.callThrough();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.setBar(123);
expect(bar).toEqual(123);
foo.setBar.and.stub();
bar = null;
foo.setBar(123);
expect(bar).toBe(null);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var foo: any, bar: any = null;
beforeEach(() => {
foo = {
setBar: (value: any) => {
bar = value;
}
};
spyOn(foo, 'setBar');
});
it("tracks if it was called at all", () => {
expect(foo.setBar.calls.any()).toEqual(false);
foo.setBar();
expect(foo.setBar.calls.any()).toEqual(true);
});
it("tracks the number of times it was called", () => {
expect(foo.setBar.calls.count()).toEqual(0);
foo.setBar();
foo.setBar();
expect(foo.setBar.calls.count()).toEqual(2);
});
it("tracks the arguments of each call", () => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.argsFor(0)).toEqual([123]);
expect(foo.setBar.calls.argsFor(1)).toEqual([456, "baz"]);
});
it("tracks the arguments of all calls", () => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.allArgs()).toEqual([[123], [456, "baz"]]);
});
it("can provide the context and arguments to all calls", () => {
foo.setBar(123);
expect(foo.setBar.calls.all()).toEqual([{ object: foo, args: [123], returnValue: undefined }]);
});
it("has a shortcut to the most recent call", () => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.mostRecent()).toEqual({ object: foo, args: [456, "baz"], returnValue: undefined });
});
it("has a shortcut to the first call", () => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.first()).toEqual({ object: foo, args: [123], returnValue: undefined });
});
it("can be reset", () => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.any()).toBe(true);
foo.setBar.calls.reset();
expect(foo.setBar.calls.any()).toBe(false);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo = {
setBar: (value: any) => {
bar = value;
}
};
spyOn(foo, 'setBar');
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo.setBar.calls.any()).toEqual(false);
foo.setBar();
expect(foo.setBar.calls.any()).toEqual(true);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(foo.setBar.calls.count()).toEqual(0);
foo.setBar();
foo.setBar();
expect(foo.setBar.calls.count()).toEqual(2);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.argsFor(0)).toEqual([123]);
expect(foo.setBar.calls.argsFor(1)).toEqual([456, "baz"]);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.allArgs()).toEqual([[123], [456, "baz"]]);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.setBar(123);
expect(foo.setBar.calls.all()).toEqual([{ object: foo, args: [123], returnValue: undefined }]);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.mostRecent()).toEqual({ object: foo, args: [456, "baz"], returnValue: undefined });
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.first()).toEqual({ object: foo, args: [123], returnValue: undefined });
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
foo.setBar(123);
foo.setBar(456, "baz");
expect(foo.setBar.calls.any()).toBe(true);
foo.setBar.calls.reset();
expect(foo.setBar.calls.any()).toBe(false);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
var whatAmI: any;
beforeEach(() => {
whatAmI = jasmine.createSpy('whatAmI');
whatAmI("I", "am", "a", "spy");
});
it("is named, which helps in error reporting", () => {
expect(whatAmI.and.identity()).toEqual('whatAmI');
});
it("tracks that the spy was called", () => {
expect(whatAmI).toHaveBeenCalled();
});
it("tracks its number of calls", () => {
expect(whatAmI.calls.count()).toEqual(1);
});
it("tracks all the arguments of its calls", () => {
expect(whatAmI).toHaveBeenCalledWith("I", "am", "a", "spy");
});
it("allows access to the most recent call", () => {
expect(whatAmI.calls.mostRecent().args[0]).toEqual("I");
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
whatAmI = jasmine.createSpy('whatAmI');
whatAmI("I", "am", "a", "spy");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(whatAmI.and.identity()).toEqual('whatAmI');
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(whatAmI).toHaveBeenCalled();
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(whatAmI.calls.count()).toEqual(1);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(whatAmI).toHaveBeenCalledWith("I", "am", "a", "spy");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
expect(whatAmI.calls.mostRecent().args[0]).toEqual("I");
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
interface Test {
method<T>(): Array<Box<T>>;
}
interface Box<T> {
value: T;
}
it("should allow to configure generic method", () => {
const spy = jasmine.createSpyObj<Test>('test', ['method']);
spy.method.and.returnValue([{ value: 1 }, { value: 2 }]);
});
it("should allow to configure generic method with non-named spy", () => {
const spy = jasmine.createSpyObj<Test>(['method']);
jasmine.createSpyObj<Test>(['methodUnknown']); // $ExpectError
spy.method.and.returnValue([{ value: 1 }, { value: 2 }]);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
const spy = jasmine.createSpyObj<Test>('test', ['method']);
spy.method.and.returnValue([{ value: 1 }, { value: 2 }]);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
const spy = jasmine.createSpyObj<Test>(['method']);
jasmine.createSpyObj<Test>(['methodUnknown']); // $ExpectError
spy.method.and.returnValue([{ value: 1 }, { value: 2 }]);
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
ArrowFunction
|
() => {
class Tape {
private rewindTo: number;
play(): void { }
pause(): void { }
rewind(pos: number): void {
this.rewindTo = pos;
}
stop(): void { }
readonly isPlaying: boolean; // spy obj makes this writable
}
var tape: Tape;
var tapeSpy: jasmine.SpyObj<Tape>;
var el: jasmine.SpyObj<Element>;
beforeEach(() => {
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();
});
it("creates spies for each requested function", () => {
expect(tape.play).toBeDefined();
expect(tape.pause).toBeDefined();
expect(tape.stop).toBeDefined();
expect(tape.rewind).toBeDefined();
});
it("tracks that the spies were called", () => {
expect(tape.play).toHaveBeenCalled();
expect(tape.pause).toHaveBeenCalled();
expect(tape.rewind).toHaveBeenCalled();
expect(tape.stop).not.toHaveBeenCalled();
});
it("tracks all the arguments of its calls", () => {
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());
});
it("read isPlaying property", () => {
expect(tape.isPlaying).toBe(false);
});
}
|
Bat-Orshikh/DefinitelyTyped
|
types/jasmine/ts3.1/jasmine-tests.ts
|
TypeScript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.