mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-05-20 19:24:34 +00:00
Adding toHaveBeenCalledBefore matcher to jasmine
This commit is contained in:
3
types/jasmine/index.d.ts
vendored
3
types/jasmine/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Jasmine 2.5.2
|
||||
// Type definitions for Jasmine 2.6.0
|
||||
// Project: http://jasmine.github.io/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Theodore Brown <https://github.com/theodorejb>, David Pärsson <https://github.com/davidparsson>, Gabe Moothart <https://github.com/gmoothart>, Lukas Zech <https://github.com/lukas-zech-software>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -427,6 +427,7 @@ declare namespace jasmine {
|
||||
toBeTruthy(expectationFailOutput?: any): boolean;
|
||||
toBeFalsy(expectationFailOutput?: any): boolean;
|
||||
toHaveBeenCalled(): boolean;
|
||||
toHaveBeenCalledBefore(expected: Spy): boolean;
|
||||
toHaveBeenCalledWith(...params: any[]): boolean;
|
||||
toHaveBeenCalledTimes(expected: number): boolean;
|
||||
toContain(expected: any, expectationFailOutput?: any): boolean;
|
||||
|
||||
@@ -270,19 +270,24 @@ describe("Pending specs", () => {
|
||||
});
|
||||
|
||||
describe("A spy", () => {
|
||||
var foo: any, bar: any = null;
|
||||
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", () => {
|
||||
@@ -294,6 +299,10 @@ describe("A spy", () => {
|
||||
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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user