forked from avajs/ava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the need for a build step. Update the `throws` and `notThrows` assertions, adding `Observable` and allowing the returned error to be typed. Remove the inline documentation, to be added later. Simplify typing of `t.context`. Reassigning the `test` method along with a type cast is now sufficient. Update to TypeScript 2.7.1.
- Loading branch information
1 parent
7c0bf9b
commit bac3c11
Showing
6 changed files
with
257 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
export interface ObservableLike { | ||
subscribe(observer: (value: any) => void): void; | ||
} | ||
|
||
export type ThrowsErrorValidator = (new (...args: Array<any>) => any) | RegExp | string | ((error: any) => boolean); | ||
|
||
export interface SnapshotOptions { | ||
id?: string; | ||
} | ||
|
||
export interface Assertions { | ||
deepEqual<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void; | ||
fail(message?: string): void; | ||
false(actual: any, message?: string): void; | ||
falsy(actual: any, message?: string): void; | ||
ifError(error: any, message?: string): void; | ||
is<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void; | ||
not<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void; | ||
notDeepEqual<ValueType = any>(actual: ValueType, expected: ValueType, message?: string): void; | ||
notRegex(string: string, regex: RegExp, message?: string): void; | ||
notThrows(value: () => never, message?: string): void; | ||
notThrows(value: () => ObservableLike, message?: string): Promise<void>; | ||
notThrows(value: () => PromiseLike<any>, message?: string): Promise<void>; | ||
notThrows(value: () => any, message?: string): void; | ||
notThrows(value: ObservableLike, message?: string): Promise<void>; | ||
notThrows(value: PromiseLike<any>, message?: string): Promise<void>; | ||
pass(message?: string): void; | ||
regex(string: string, regex: RegExp, message?: string): void; | ||
snapshot(expected: any, message?: string): void; | ||
snapshot(expected: any, options: SnapshotOptions, message?: string): void; | ||
throws(value: () => never, error?: ThrowsErrorValidator, message?: string): any; | ||
throws(value: () => ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>; | ||
throws(value: () => PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>; | ||
throws(value: () => any, error?: ThrowsErrorValidator, message?: string): any; | ||
throws(value: ObservableLike, error?: ThrowsErrorValidator, message?: string): Promise<any>; | ||
throws(value: PromiseLike<any>, error?: ThrowsErrorValidator, message?: string): Promise<any>; | ||
true(actual: any, message?: string): void; | ||
truthy(actual: any, message?: string): void; | ||
} | ||
|
||
export interface ExecutionContext<Context = {}> extends Assertions { | ||
context: Context; | ||
skip: Assertions; | ||
title: string; | ||
log(...values: Array<any>): void; | ||
plan(count: number): void; | ||
} | ||
|
||
export interface CbExecutionContext<Context = {}> extends ExecutionContext<Context> { | ||
end(): void; | ||
} | ||
|
||
export type ImplementationResult = PromiseLike<void> | ObservableLike | Iterator<any> | void; | ||
export type Implementation<Context = {}> = (t: ExecutionContext<Context>) => ImplementationResult; | ||
export type CbImplementation<Context = {}> = (t: CbExecutionContext<Context>) => ImplementationResult; | ||
|
||
export interface Macro<Context = {}> { | ||
(t: ExecutionContext<Context>, ...args: Array<any>): ImplementationResult; | ||
title?: (providedTitle: string, ...args: Array<any>) => string; | ||
} | ||
|
||
export interface CbMacro<Context = {}> { | ||
(t: CbExecutionContext<Context>, ...args: Array<any>): ImplementationResult; | ||
title?: (providedTitle: string, ...args: Array<any>) => string; | ||
} | ||
|
||
export interface TestInterface<Context = {}> { | ||
(title: string, implementation: Implementation<Context>): void; | ||
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
|
||
after: AfterInterface<null>; | ||
afterEach: AfterInterface<Context>; | ||
before: BeforeInterface<null>; | ||
beforeEach: BeforeInterface<Context>; | ||
cb: CbInterface<Context>; | ||
failing: FailingInterface<Context>; | ||
only: OnlyInterface<Context>; | ||
serial: SerialInterface<Context>; | ||
skip: SkipInterface<Context>; | ||
todo: TodoDeclaration; | ||
} | ||
|
||
export interface AfterInterface<Context = {}> { | ||
(title: string, implementation: Implementation<Context>): void; | ||
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
|
||
always: AlwaysInterface<Context>; | ||
cb: HookCbInterface<Context>; | ||
skip: SkipInterface<Context>; | ||
} | ||
|
||
export interface AlwaysInterface<Context = {}> { | ||
(title: string, implementation: Implementation<Context>): void; | ||
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
|
||
cb: HookCbInterface<Context>; | ||
skip: SkipInterface<Context>; | ||
} | ||
|
||
export interface BeforeInterface<Context = {}> { | ||
(title: string, implementation: Implementation<Context>): void; | ||
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
|
||
cb: HookCbInterface<Context>; | ||
skip: SkipInterface<Context>; | ||
} | ||
|
||
export interface CbInterface<Context = {}> { | ||
(title: string, implementation: CbImplementation<Context>): void; | ||
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
|
||
failing: CbFailingInterface<Context>; | ||
only: CbOnlyInterface<Context>; | ||
skip: CbSkipInterface<Context>; | ||
} | ||
|
||
export interface CbFailingInterface<Context = {}> { | ||
(title: string, implementation: CbImplementation<Context>): void; | ||
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
|
||
only: CbOnlyInterface<Context>; | ||
skip: CbSkipInterface<Context>; | ||
} | ||
|
||
export interface CbOnlyInterface<Context = {}> { | ||
(title: string, implementation: CbImplementation<Context>): void; | ||
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
} | ||
|
||
export interface CbSkipInterface<Context = {}> { | ||
(title: string, implementation: CbImplementation<Context>): void; | ||
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
} | ||
|
||
export interface FailingInterface<Context = {}> { | ||
(title: string, implementation: Implementation<Context>): void; | ||
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
|
||
only: OnlyInterface<Context>; | ||
skip: SkipInterface<Context>; | ||
} | ||
|
||
export interface HookCbInterface<Context = {}> { | ||
(title: string, implementation: CbImplementation<Context>): void; | ||
(title: string, macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
(macro: CbMacro<Context> | CbMacro<Context>[], ...args: Array<any>): void; | ||
|
||
skip: CbSkipInterface<Context>; | ||
} | ||
|
||
export interface OnlyInterface<Context = {}> { | ||
(title: string, implementation: Implementation<Context>): void; | ||
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
} | ||
|
||
export interface SerialInterface<Context = {}> { | ||
(title: string, implementation: Implementation<Context>): void; | ||
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
|
||
cb: CbInterface<Context>; | ||
failing: FailingInterface<Context>; | ||
only: OnlyInterface<Context>; | ||
skip: SkipInterface<Context>; | ||
todo: TodoDeclaration; | ||
} | ||
|
||
export interface SkipInterface<Context = {}> { | ||
(title: string, implementation: Implementation<Context>): void; | ||
(title: string, macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
(macro: Macro<Context> | Macro<Context>[], ...args: Array<any>): void; | ||
} | ||
|
||
export type TodoDeclaration = (title: string) => void; | ||
|
||
declare const test: TestInterface; | ||
export default test; | ||
|
||
export {test}; | ||
export const after: AfterInterface<null>; | ||
export const afterEach: AfterInterface; | ||
export const before: BeforeInterface<null>; | ||
export const beforeEach: BeforeInterface; | ||
export const cb: CbInterface; | ||
export const failing: FailingInterface; | ||
export const only: OnlyInterface; | ||
export const serial: SerialInterface; | ||
export const skip: SkipInterface; | ||
export const todo: TodoDeclaration; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.