|
| 1 | +export interface ObservableLike { |
| 2 | + subscribe(observer: (value: any) => void): void; |
| 3 | +} |
| 4 | + |
| 5 | +export type ThrowsErrorValidator = (new (...args: Array<any>) => any) | RegExp | string | ((error: any) => boolean); |
| 6 | + |
| 7 | +export interface SnapshotOptions { |
| 8 | + id?: string; |
| 9 | +} |
| 10 | + |
| 11 | +export interface Assertions { |
| 12 | + deepEqual<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void; |
| 13 | + fail(message?: string): void; |
| 14 | + false(actual: any, message?: string): void; |
| 15 | + falsy(actual: any, message?: string): void; |
| 16 | + ifError(error: any, message?: string): void; |
| 17 | + is<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void; |
| 18 | + not<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void; |
| 19 | + notDeepEqual<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void; |
| 20 | + notRegex(string: string, regex: RegExp, message?: string): void; |
| 21 | + notThrows(value: () => never, message?: string): void; |
| 22 | + notThrows(value: () => ObservableLike, message?: string): Promise<void>; |
| 23 | + notThrows(value: () => PromiseLike<any>, message?: string): Promise<void>; |
| 24 | + notThrows(value: () => any, message?: string): void; |
| 25 | + notThrows(value: ObservableLike, message?: string): Promise<void>; |
| 26 | + notThrows(value: PromiseLike<any>, message?: string): Promise<void>; |
| 27 | + pass(message?: string): void; |
| 28 | + regex(string: string, regex: RegExp, message?: string): void; |
| 29 | + snapshot(expected: any, message?: string): void; |
| 30 | + snapshot(expected: any, options: SnapshotOptions, message?: string): void; |
| 31 | + throws(value: () => never, error?: ThrowsErrorValidator, message?: string): any; |
| 32 | + throws(value: () => ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>; |
| 33 | + throws(value: () => PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>; |
| 34 | + throws(value: () => any, error?: ThrowsErrorValidator, message?: string): any; |
| 35 | + throws(value: ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>; |
| 36 | + throws(value: PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>; |
| 37 | + true(actual: any, message?: string): void; |
| 38 | + truthy(actual: any, message?: string): void; |
| 39 | +} |
| 40 | + |
| 41 | +export interface ExecutionContext<Context = {}> extends Assertions { |
| 42 | + context: Context; |
| 43 | + skip: Assertions; |
| 44 | + title: string; |
| 45 | + log(...values: Array<any>): void; |
| 46 | + plan(count: number): void; |
| 47 | +} |
| 48 | + |
| 49 | +export interface CbExecutionContext<Context = {}> extends ExecutionContext<Context> { |
| 50 | + end(): void; |
| 51 | +} |
| 52 | + |
| 53 | +export type ImplementationResult = PromiseLike<void> | ObservableLike | Iterator<any> | void; |
| 54 | +export type Implementation<Context = {}> = (t: ExecutionContext<Context>) => ImplementationResult; |
| 55 | +export type CbImplementation<Context = {}> = (t: CbExecutionContext<Context>) => ImplementationResult; |
| 56 | + |
| 57 | +export interface Macro<Context = {}> { |
| 58 | + (t: ExecutionContext<Context>, ...args: Array<any>): ImplementationResult; |
| 59 | + title?: (providedTitle: string, ...args: Array<any>) => string; |
| 60 | +} |
| 61 | + |
| 62 | +export interface CbMacro<Context = {}> { |
| 63 | + (t: CbExecutionContext<Context>, ...args: Array<any>): ImplementationResult; |
| 64 | + title?: (providedTitle: string, ...args: Array<any>) => string; |
| 65 | +} |
| 66 | + |
| 67 | +export interface TestInterface<Context = {}> { |
| 68 | + (title: string, implementation: Implementation<Context>): void; |
| 69 | + (title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 70 | + (macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 71 | + |
| 72 | + after: AfterInterface<null>; |
| 73 | + afterEach: AfterInterface<Context>; |
| 74 | + before: BeforeInterface<null>; |
| 75 | + beforeEach: BeforeInterface<Context>; |
| 76 | + cb: CbInterface<Context>; |
| 77 | + failing: FailingInterface<Context>; |
| 78 | + only: OnlyInterface<Context>; |
| 79 | + serial: SerialInterface<Context>; |
| 80 | + skip: SkipInterface<Context>; |
| 81 | + todo: TodoDeclaration; |
| 82 | +} |
| 83 | + |
| 84 | +export interface AfterInterface<Context = {}> { |
| 85 | + (title: string, implementation: Implementation<Context>): void; |
| 86 | + (title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 87 | + (macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 88 | + |
| 89 | + always: AlwaysInterface<Context>; |
| 90 | + cb: HookCbInterface<Context>; |
| 91 | + skip: SkipInterface<Context>; |
| 92 | +} |
| 93 | + |
| 94 | +export interface AlwaysInterface<Context = {}> { |
| 95 | + (title: string, implementation: Implementation<Context>): void; |
| 96 | + (title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 97 | + (macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 98 | + |
| 99 | + cb: HookCbInterface<Context>; |
| 100 | + skip: SkipInterface<Context>; |
| 101 | +} |
| 102 | + |
| 103 | +export interface BeforeInterface<Context = {}> { |
| 104 | + (title: string, implementation: Implementation<Context>): void; |
| 105 | + (title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 106 | + (macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 107 | + |
| 108 | + cb: HookCbInterface<Context>; |
| 109 | + skip: SkipInterface<Context>; |
| 110 | +} |
| 111 | + |
| 112 | +export interface CbInterface<Context = {}> { |
| 113 | + (title: string, implementation: CbImplementation<Context>): void; |
| 114 | + (title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 115 | + (macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 116 | + |
| 117 | + failing: CbFailingInterface<Context>; |
| 118 | + only: CbOnlyInterface<Context>; |
| 119 | + skip: CbSkipInterface<Context>; |
| 120 | +} |
| 121 | + |
| 122 | +export interface CbFailingInterface<Context = {}> { |
| 123 | + (title: string, implementation: CbImplementation<Context>): void; |
| 124 | + (title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 125 | + (macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 126 | + |
| 127 | + only: CbOnlyInterface<Context>; |
| 128 | + skip: CbSkipInterface<Context>; |
| 129 | +} |
| 130 | + |
| 131 | +export interface CbOnlyInterface<Context = {}> { |
| 132 | + (title: string, implementation: CbImplementation<Context>): void; |
| 133 | + (title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 134 | + (macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 135 | +} |
| 136 | + |
| 137 | +export interface CbSkipInterface<Context = {}> { |
| 138 | + (title: string, implementation: CbImplementation<Context>): void; |
| 139 | + (title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 140 | + (macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 141 | +} |
| 142 | + |
| 143 | +export interface FailingInterface<Context = {}> { |
| 144 | + (title: string, implementation: Implementation<Context>): void; |
| 145 | + (title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 146 | + (macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 147 | + |
| 148 | + only: OnlyInterface<Context>; |
| 149 | + skip: SkipInterface<Context>; |
| 150 | +} |
| 151 | + |
| 152 | +export interface HookCbInterface<Context = {}> { |
| 153 | + (title: string, implementation: CbImplementation<Context>): void; |
| 154 | + (title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 155 | + (macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; |
| 156 | + |
| 157 | + skip: CbSkipInterface<Context>; |
| 158 | +} |
| 159 | + |
| 160 | +export interface OnlyInterface<Context = {}> { |
| 161 | + (title: string, implementation: Implementation<Context>): void; |
| 162 | + (title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 163 | + (macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 164 | +} |
| 165 | + |
| 166 | +export interface SerialInterface<Context = {}> { |
| 167 | + (title: string, implementation: Implementation<Context>): void; |
| 168 | + (title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 169 | + (macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 170 | + |
| 171 | + cb: CbInterface<Context>; |
| 172 | + failing: FailingInterface<Context>; |
| 173 | + only: OnlyInterface<Context>; |
| 174 | + skip: SkipInterface<Context>; |
| 175 | + todo: TodoDeclaration; |
| 176 | +} |
| 177 | + |
| 178 | +export interface SkipInterface<Context = {}> { |
| 179 | + (title: string, implementation: Implementation<Context>): void; |
| 180 | + (title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 181 | + (macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; |
| 182 | +} |
| 183 | + |
| 184 | +export type TodoDeclaration = (title: string) => void; |
| 185 | + |
| 186 | +declare const test: TestInterface; |
| 187 | +export default test; |
| 188 | + |
| 189 | +export {test}; |
| 190 | +export const after: AfterInterface<null>; |
| 191 | +export const afterEach: AfterInterface; |
| 192 | +export const before: BeforeInterface<null>; |
| 193 | +export const beforeEach: BeforeInterface; |
| 194 | +export const cb: CbInterface; |
| 195 | +export const failing: FailingInterface; |
| 196 | +export const only: OnlyInterface; |
| 197 | +export const serial: SerialInterface; |
| 198 | +export const skip: SkipInterface; |
| 199 | +export const todo: TodoDeclaration; |
0 commit comments