Skip to content

Commit

Permalink
support test macros in typescript definitions (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMurphy authored and sindresorhus committed Aug 11, 2016
1 parent ea25b20 commit 8816faf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,13 @@ export interface ContextualCallbackTestContext extends CallbackTestContext {
context: any;
}

export interface Macro<T> {
(t: T, ...args: any[]): void;
title? (providedTitle: string, ...args: any[]): string;
}
export type Macros<T> = Macro<T> | Macro<T>[];

export function test(name: string, run: ContextualTest): void;
export function test(run: ContextualTest): void;
export function test(name: string, run: Macros<ContextualTestContext>, ...args: any[]): void;
export function test(run: Macros<ContextualTestContext>, ...args: any[]): void;
2 changes: 2 additions & 0 deletions types/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ function generatePrefixed(prefix) {
const type = testType(parts);
output += '\t' + writeFunction(part, 'name: string, implementation: ' + type);
output += '\t' + writeFunction(part, 'implementation: ' + type);
output += '\t' + writeFunction(part, 'name: string, implementation: Macros<' + type + 'Context>, ...args: any[]');
output += '\t' + writeFunction(part, 'implementation: Macros<' + type + 'Context>, ...args: any[]');
}
}

Expand Down

0 comments on commit 8816faf

Please sign in to comment.