forked from joefitzgerald/go-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjasmine.js.flow
109 lines (91 loc) · 3.17 KB
/
jasmine.js.flow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*
* @flow
*/
// Type declarations for Jasmine v1.3
// https://jasmine.github.io/1.3/introduction.html
// Disabling Specs and Suites
// https://jasmine.github.io/1.3/introduction.html#section-Disabling_Specs_and_Suites
declare function xdescribe(title: string, spec: () => mixed): void;
declare function xit(title: string, spec: () => mixed): void;
// Declaring, describing, and grouping tests
declare function afterEach(func: () => mixed): void;
declare function beforeEach(func: () => mixed): void;
declare function describe(title: string, spec: () => mixed): void;
declare function expect(actual: mixed): any;
declare function it(title: string, spec: () => mixed): void;
// Spies
// https://jasmine.github.io/1.3/introduction.html#section-Spies
type JasmineSpyCall = {
args: Array<mixed>,
};
type JasmineSpy = {
(...args: Array<any>): any,
andCallFake(fake: (...args: Array<any>) => mixed): JasmineSpy,
andCallThrough(): JasmineSpy,
argsForCall: Array<Array<mixed>>,
andReturn<T>(value: T): JasmineSpy,
andThrow(error: mixed): JasmineSpy,
callCount: number,
calls: Array<JasmineSpyCall>,
identity: string,
mostRecentCall: JasmineSpyCall,
wasCalled: boolean,
reset(): void,
};
declare function spyOn(object: Object, method: string): JasmineSpy;
// Mocking the JavaScript Clock
// https://jasmine.github.io/1.3/introduction.html#section-Mocking_the_JavaScript_Clock
type JasmineMockClock = {
tick(milliseconds: number): void,
useMock(): void,
};
// Asynchronous Support
// https://jasmine.github.io/1.3/introduction.html#section-Asynchronous_Support
declare function runs(func: () => mixed): void;
// Apparently the arguments for waitsFor() can be specified in any order.
type WaitsForArg = string | number | () => mixed;
declare function waitsFor(
latchFunction?: WaitsForArg, failureMessage?: WaitsForArg, timeout?: WaitsForArg): void;
declare function waits(milliseconds: number): void;
type JasmineEnvironment = {
currentSpec: {
fail(message: string): void,
},
defaultTimeoutInterval: number,
afterEach: any,
beforeEach: any,
describe: any,
it: any,
};
type JasmineSpec = {
addMatchers(matchersPrototype: {[methodName: string]: (expected: any) => boolean}): void,
};
type JasmineMatchers = {
message: () => string,
};
// Jasmine global
declare var jasmine: {
// Default timeout.
DEFAULT_TIMEOUT_INTERVAL: number,
Clock: JasmineMockClock,
Matchers: JasmineMatchers,
any(expected: string | Object): mixed,
/**
* This is a non-standard method that Atom adds to Jasmine via spec-helper.coffee.
* Ideally, we would declare this in atom-jasmine.js, but we can't extend this global here.
*/
attachToDOM(element: Element): ?HTMLElement,
createSpy: (name?: string) => JasmineSpy,
createSpyObj: (name: string, spyNames: Array<string>) => {[key: string]: JasmineSpy},
getEnv: () => JasmineEnvironment,
pp: (value: mixed) => string,
unspy: (obj: Object, methodName: string) => void,
useMockClock: () => void,
useRealClock: () => void,
};