UNPKG

2.1 kBTypeScriptView Raw
1// Imported from: https://github.com/soywiz/typescript-node-definitions/nodeunit.d.ts
2
3export interface ITestCase {
4 (testCase: { [property: string]: ITestBody | ITestGroup | void }): void;
5}
6export declare var testCase: ITestCase;
7
8export interface Test {
9 done: ICallbackFunction;
10 expect(num: number): void;
11
12 // assersions from node assert module
13 fail(actual: any, expected: any, message: string, operator: string): void;
14 assert(value: any, message: string): void;
15 ok(value: any, message?: string): void;
16 equal(actual: any, expected: any, message?: string): void;
17 notEqual(actual: any, expected: any, message?: string): void;
18 deepEqual(actual: any, expected: any, message?: string): void;
19 notDeepEqual(actual: any, expected: any, message?: string): void;
20 strictEqual(actual: any, expected: any, message?: string): void;
21 notStrictEqual(actual: any, expected: any, message?: string): void;
22 throws(block: any, error?: any, message?: string): void;
23 doesNotThrow(block: any, error?: any, message?: string): void;
24 ifError(value: any): void;
25
26 // assertion wrappers
27 equals(actual: any, expected: any, message?: string): void;
28 same(actual: any, expected: any, message?: string): void;
29}
30
31// Test Group Usage:
32// var testGroup: nodeunit.ITestGroup = {
33// setUp: (callback) => {
34// callback();
35// },
36// tearDown: (callback) => {
37// callback();
38// },
39// test1: (test: nodeunit.Test) => {
40// test.done();
41// }
42// }
43// exports.testgroup = testGroup;
44
45export interface ITestBody {
46 (callback: Test): void;
47}
48
49export interface ITestGroup {
50 /** The setUp function is run before each test */
51 setUp?: ((callback: ICallbackFunction) => void) | undefined;
52 /** The tearDown function is run after each test calls test.done() */
53 tearDown?: ((callback: ICallbackFunction) => void) | undefined;
54 [property: string]: ITestGroup | ITestBody | ((callback: ICallbackFunction) => void) | undefined;
55}
56
57export interface ICallbackFunction {
58 (err?: any): void;
59}
60
\No newline at end of file