UNPKG

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