From 8816faf6bee675213c5bfe32f628a0a683708484 Mon Sep 17 00:00:00 2001 From: Christian Murphy Date: Thu, 11 Aug 2016 06:27:51 -0700 Subject: [PATCH] support test macros in typescript definitions (#975) --- types/base.d.ts | 8 ++++++++ types/make.js | 2 ++ 2 files changed, 10 insertions(+) diff --git a/types/base.d.ts b/types/base.d.ts index 3bebc6c..a827291 100644 --- a/types/base.d.ts +++ b/types/base.d.ts @@ -120,5 +120,13 @@ export interface ContextualCallbackTestContext extends CallbackTestContext { context: any; } +export interface Macro { + (t: T, ...args: any[]): void; + title? (providedTitle: string, ...args: any[]): string; +} +export type Macros = Macro | Macro[]; + export function test(name: string, run: ContextualTest): void; export function test(run: ContextualTest): void; +export function test(name: string, run: Macros, ...args: any[]): void; +export function test(run: Macros, ...args: any[]): void; diff --git a/types/make.js b/types/make.js index f33fb2f..658c502 100644 --- a/types/make.js +++ b/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[]'); } }