Browse Source

support test macros in typescript definitions (#975)

hoisting-throws-helper
Christian Murphy 8 years ago
committed by Sindre Sorhus
parent
commit
8816faf6be
  1. 8
      types/base.d.ts
  2. 2
      types/make.js

8
types/base.d.ts

@ -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
types/make.js

@ -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[]');
}
}

Loading…
Cancel
Save