Skip to content

Commit df4c368

Browse files
support test macros in typescript definitions
1 parent 1c6abe0 commit df4c368

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

types/base.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,12 @@ export interface ContextualCallbackTestContext extends CallbackTestContext {
120120
context: any;
121121
}
122122

123+
export interface Macro<I, E, T> {
124+
(t: T, input: I, expected: E): void;
125+
title? (providedTitle: string, input: I, expected: E): string;
126+
}
127+
123128
export function test(name: string, run: ContextualTest): void;
124129
export function test(run: ContextualTest): void;
130+
export function test<I, E> (run: Macro<I, E, ContextualTestContext> | Macro<I, E, ContextualTestContext>[], input: I, expected: E): void;
131+
export function test<I, E> (name: string, run: Macro<I, E, ContextualTestContext> | Macro<I, E, ContextualTestContext>[], input: I, expected: E): void;

types/make.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ function generatePrefixed(prefix) {
5151
output += '\t' + writeFunction(part, 'name: string', 'void');
5252
} else {
5353
const type = testType(parts);
54+
output += '\t' + writeFunction(part + '<I, E>', 'implementation: Macro<I, E, ' + type + 'Context>, input: I, expected: E');
55+
output += '\t' + writeFunction(part + '<I, E>', 'name: string, implementation: Macro<I, E, ' + type + 'Context>, input: I, expected: E');
5456
output += '\t' + writeFunction(part, 'name: string, implementation: ' + type);
5557
output += '\t' + writeFunction(part, 'implementation: ' + type);
5658
}

0 commit comments

Comments
 (0)