mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-18 20:37:14 +08:00
Merge pull request #6976 from sodatea/tape4
Update tape.d.ts for tape v4.2.2
This commit is contained in:
@@ -2,23 +2,18 @@
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import tape = require('tape');
|
||||
import tape = require("tape");
|
||||
|
||||
var x: any;
|
||||
var value: any;
|
||||
var err: any;
|
||||
var a: any;
|
||||
var b: any;
|
||||
var err: any;
|
||||
var num: number;
|
||||
var name: string;
|
||||
var msg: string;
|
||||
var rs: NodeJS.ReadableStream;
|
||||
|
||||
var cb: tape.TestCase;
|
||||
var opts: tape.TestOptions;
|
||||
var t: tape.Test;
|
||||
|
||||
tape(cb);
|
||||
tape(name, cb);
|
||||
tape(opts, cb);
|
||||
tape(name, opts, cb);
|
||||
|
||||
tape(name, (test: tape.Test) => {
|
||||
t = test;
|
||||
});
|
||||
@@ -26,29 +21,51 @@ tape(name, (test: tape.Test) => {
|
||||
tape.skip(name, cb);
|
||||
tape.only(name, cb);
|
||||
|
||||
rs = tape.createStream();
|
||||
rs = tape.createStream(x);
|
||||
|
||||
var tx = tape.createHarness();
|
||||
tx(name, cb);
|
||||
tape.skip(name, cb);
|
||||
tape.only(name, cb);
|
||||
var sopts: tape.StreamOptions;
|
||||
var rs: NodeJS.ReadableStream;
|
||||
rs = tape.createStream();
|
||||
rs = tape.createStream(sopts);
|
||||
|
||||
|
||||
var htest: typeof tape;
|
||||
htest = tape.createHarness();
|
||||
|
||||
|
||||
tape(name, (test: tape.Test) => {
|
||||
|
||||
var num: number;
|
||||
var ms: number;
|
||||
var value: any;
|
||||
var actual: any;
|
||||
var expected: any;
|
||||
var err: any;
|
||||
var fn = function() {};
|
||||
var msg: string;
|
||||
|
||||
var exceptionExpected: RegExp | (() => void);
|
||||
|
||||
test.plan(num);
|
||||
test.end();
|
||||
test.end(err);
|
||||
|
||||
test.fail(msg);
|
||||
test.pass(msg);
|
||||
test.timeoutAfter(ms);
|
||||
test.skip(msg);
|
||||
|
||||
test.ok(value);
|
||||
test.ok(value, msg);
|
||||
test.true(value);
|
||||
test.true(value, msg);
|
||||
test.assert(value);
|
||||
test.assert(value, msg);
|
||||
|
||||
test.notOk(value);
|
||||
test.notOk(value, msg);
|
||||
test.false(value);
|
||||
test.false(value, msg);
|
||||
test.notok(value);
|
||||
test.notok(value, msg);
|
||||
|
||||
test.error(err, msg);
|
||||
@@ -56,51 +73,91 @@ tape(name, (test: tape.Test) => {
|
||||
test.ifErr(err, msg);
|
||||
test.iferror(err, msg);
|
||||
|
||||
test.equal(a, b, msg);
|
||||
test.equals(a, b, msg);
|
||||
test.isEqual(a, b, msg);
|
||||
test.is(a, b, msg);
|
||||
test.strictEqual(a, b, msg);
|
||||
test.strictEquals(a, b, msg);
|
||||
test.equal(actual, expected);
|
||||
test.equal(actual, expected, msg);
|
||||
test.equals(actual, expected);
|
||||
test.equals(actual, expected, msg);
|
||||
test.isEqual(actual, expected);
|
||||
test.isEqual(actual, expected, msg);
|
||||
test.is(actual, expected);
|
||||
test.is(actual, expected, msg);
|
||||
test.strictEqual(actual, expected);
|
||||
test.strictEqual(actual, expected, msg);
|
||||
test.strictEquals(actual, expected);
|
||||
test.strictEquals(actual, expected, msg);
|
||||
|
||||
test.notEqual(a, b, msg);
|
||||
test.notEquals(a, b, msg);
|
||||
test.notStrictEqual(a, b, msg);
|
||||
test.notStrictEquals(a, b, msg);
|
||||
test.isNotEqual(a, b, msg);
|
||||
test.isNot(a, b, msg);
|
||||
test.not(a, b, msg);
|
||||
test.doesNotEqual(a, b, msg);
|
||||
test.notEqual(a, b, msg);
|
||||
test.isInequal(a, b, msg);
|
||||
test.notEqual(actual, expected);
|
||||
test.notEqual(actual, expected, msg);
|
||||
test.notEquals(actual, expected);
|
||||
test.notEquals(actual, expected, msg);
|
||||
test.notStrictEqual(actual, expected);
|
||||
test.notStrictEqual(actual, expected, msg);
|
||||
test.notStrictEquals(actual, expected);
|
||||
test.notStrictEquals(actual, expected, msg);
|
||||
test.isNotEqual(actual, expected);
|
||||
test.isNotEqual(actual, expected, msg);
|
||||
test.isNot(actual, expected);
|
||||
test.isNot(actual, expected, msg);
|
||||
test.not(actual, expected);
|
||||
test.not(actual, expected, msg);
|
||||
test.doesNotEqual(actual, expected);
|
||||
test.doesNotEqual(actual, expected, msg);
|
||||
test.isInequal(actual, expected);
|
||||
test.isInequal(actual, expected, msg);
|
||||
|
||||
test.deepEqual(a, b, msg);
|
||||
test.deepEquals(a, b, msg);
|
||||
test.isEquivalent(a, b, msg);
|
||||
test.same(a, b, msg);
|
||||
test.deepEqual(actual, expected);
|
||||
test.deepEqual(actual, expected, msg);
|
||||
test.deepEquals(actual, expected);
|
||||
test.deepEquals(actual, expected, msg);
|
||||
test.isEquivalent(actual, expected);
|
||||
test.isEquivalent(actual, expected, msg);
|
||||
test.same(actual, expected);
|
||||
test.same(actual, expected, msg);
|
||||
|
||||
test.notDeepEqual(a, b, msg);
|
||||
test.notEquivalent(a, b, msg);
|
||||
test.notDeeply(a, b, msg);
|
||||
test.notSame(a, b, msg);
|
||||
test.isNotDeepEqual(a, b, msg);
|
||||
test.isNotDeeply(a, b, msg);
|
||||
test.isNotEquivalent(a, b, msg);
|
||||
test.isInequivalent(a, b, msg);
|
||||
test.notDeepEqual(actual, expected);
|
||||
test.notDeepEqual(actual, expected, msg);
|
||||
test.notEquivalent(actual, expected);
|
||||
test.notEquivalent(actual, expected, msg);
|
||||
test.notDeeply(actual, expected);
|
||||
test.notDeeply(actual, expected, msg);
|
||||
test.notSame(actual, expected);
|
||||
test.notSame(actual, expected, msg);
|
||||
test.isNotDeepEqual(actual, expected);
|
||||
test.isNotDeepEqual(actual, expected, msg);
|
||||
test.isNotDeeply(actual, expected);
|
||||
test.isNotDeeply(actual, expected, msg);
|
||||
test.isNotEquivalent(actual, expected);
|
||||
test.isNotEquivalent(actual, expected, msg);
|
||||
test.isInequivalent(actual, expected);
|
||||
test.isInequivalent(actual, expected, msg);
|
||||
|
||||
test.deepLooseEqual(a, b, msg);
|
||||
test.looseEqual(a, b, msg);
|
||||
test.looseEquals(a, b, msg);
|
||||
test.deepLooseEqual(actual, expected);
|
||||
test.deepLooseEqual(actual, expected, msg);
|
||||
test.looseEqual(actual, expected);
|
||||
test.looseEqual(actual, expected, msg);
|
||||
test.looseEquals(actual, expected);
|
||||
test.looseEquals(actual, expected, msg);
|
||||
|
||||
test.notDeepLooseEqual(a, b, msg);
|
||||
test.notLooseEqual(a, b, msg);
|
||||
test.notLooseEquals(a, b, msg);
|
||||
test.notDeepLooseEqual(actual, expected);
|
||||
test.notDeepLooseEqual(actual, expected, msg);
|
||||
test.notLooseEqual(actual, expected);
|
||||
test.notLooseEqual(actual, expected, msg);
|
||||
test.notLooseEquals(actual, expected);
|
||||
test.notLooseEquals(actual, expected, msg);
|
||||
|
||||
test.throws(() => {
|
||||
test.throws(fn);
|
||||
test.throws(fn, msg);
|
||||
test.throws(fn, exceptionExpected);
|
||||
test.throws(fn, exceptionExpected, msg);
|
||||
|
||||
}, value, msg);
|
||||
test.doesNotThrow(fn);
|
||||
test.doesNotThrow(fn, msg);
|
||||
test.doesNotThrow(fn, exceptionExpected);
|
||||
test.doesNotThrow(fn, exceptionExpected, msg);
|
||||
|
||||
test.doesNotThrow(() => {
|
||||
test.test(name, (st) => {
|
||||
t = st;
|
||||
});
|
||||
|
||||
}, value, msg);
|
||||
test.comment(msg);
|
||||
});
|
||||
|
||||
63
tape/tape.d.ts
vendored
63
tape/tape.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for tape v2.12.3
|
||||
// Type definitions for tape v4.2.2
|
||||
// Project: https://github.com/substack/tape
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Haoqun Jiang <https://github.com/sodatea>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
@@ -9,22 +9,43 @@ declare module 'tape' {
|
||||
export = tape;
|
||||
|
||||
/**
|
||||
* Create a new test with an optional name string. cb(t) fires with the new test object t once all preceeding tests have finished. Tests execute serially.
|
||||
* Create a new test with an optional name string and optional opts object.
|
||||
* cb(t) fires with the new test object t once all preceeding tests have finished.
|
||||
* Tests execute serially.
|
||||
*/
|
||||
function tape(name: string, cb: tape.TestCase): void;
|
||||
function tape(name: string, opts: tape.TestOptions, cb: tape.TestCase): void;
|
||||
function tape(cb: tape.TestCase): void;
|
||||
function tape(opts: tape.TestOptions, cb: tape.TestCase): void;
|
||||
|
||||
module tape {
|
||||
|
||||
interface TestCase {
|
||||
(test: Test): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available opts options for the tape function.
|
||||
*/
|
||||
interface TestOptions {
|
||||
skip?: boolean; // See tape.skip.
|
||||
timeout?: number; // Set a timeout for the test, after which it will fail. See tape.timeoutAfter.
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for the createStream function.
|
||||
*/
|
||||
interface StreamOptions {
|
||||
objectMode?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new test that will be skipped over.
|
||||
*/
|
||||
export function skip(name: string, cb: tape.TestCase): void;
|
||||
|
||||
/**
|
||||
* Like test(name, cb) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored
|
||||
* Like test(name, cb) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored.
|
||||
*/
|
||||
export function only(name: string, cb: tape.TestCase): void;
|
||||
|
||||
@@ -34,24 +55,29 @@ declare module 'tape' {
|
||||
export function createHarness(): typeof tape;
|
||||
/**
|
||||
* Create a stream of output, bypassing the default output stream that writes messages to console.log().
|
||||
* By default stream will be a text stream of TAP output, but you can get an object stream instead by setting opts.objectMode to true.
|
||||
*/
|
||||
export function createStream(opts?: any): NodeJS.ReadableStream;
|
||||
export function createStream(opts?: tape.StreamOptions): NodeJS.ReadableStream;
|
||||
|
||||
interface Test {
|
||||
/**
|
||||
* Create a subtest with a new test handle st from cb(st) inside the current test cb(st) will only fire when t finishes. Additional tests queued up after t will not be run until all subtests finish.
|
||||
* Create a subtest with a new test handle st from cb(st) inside the current test.
|
||||
* cb(st) will only fire when t finishes.
|
||||
* Additional tests queued up after t will not be run until all subtests finish.
|
||||
*/
|
||||
test(name: string, cb: tape.TestCase): void;
|
||||
|
||||
/**
|
||||
* Declare that n assertions should be run. end() will be called automatically after the nth assertion. If there are any more assertions after the nth, or after end() is called, they will generate errors.
|
||||
* Declare that n assertions should be run. end() will be called automatically after the nth assertion.
|
||||
* If there are any more assertions after the nth, or after end() is called, they will generate errors.
|
||||
*/
|
||||
plan(n: number): void;
|
||||
|
||||
/**
|
||||
* Declare the end of a test explicitly.
|
||||
* If err is passed in t.end will assert that it is falsey.
|
||||
*/
|
||||
end(): void;
|
||||
end(err?: any): void;
|
||||
|
||||
/**
|
||||
* Generate a failing assertion with a message msg.
|
||||
@@ -63,6 +89,11 @@ declare module 'tape' {
|
||||
*/
|
||||
pass(msg?: string): void;
|
||||
|
||||
/**
|
||||
* Automatically timeout the test after X ms.
|
||||
*/
|
||||
timeoutAfter(ms: number): void;
|
||||
|
||||
/**
|
||||
* Generate an assertion that will be skipped over.
|
||||
*/
|
||||
@@ -83,7 +114,8 @@ declare module 'tape' {
|
||||
notok(value: any, msg?: string): void;
|
||||
|
||||
/**
|
||||
* Assert that err is falsy. If err is non-falsy, use its err.message as the description message.
|
||||
* Assert that err is falsy.
|
||||
* If err is non-falsy, use its err.message as the description message.
|
||||
*/
|
||||
error(err: any, msg?: string): void;
|
||||
ifError(err: any, msg?: string): void;
|
||||
@@ -149,13 +181,22 @@ declare module 'tape' {
|
||||
|
||||
/**
|
||||
* Assert that the function call fn() throws an exception.
|
||||
* expected, if present, must be a RegExp or Function, which is used to test the exception object.
|
||||
*/
|
||||
throws(fn: () => void, expected: any, msg?: string): void;
|
||||
throws(fn: () => void, msg?: string): void;
|
||||
throws(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void;
|
||||
|
||||
/**
|
||||
* Assert that the function call fn() does not throw an exception.
|
||||
*/
|
||||
doesNotThrow(fn: () => void, expected: any, msg?: string): void;
|
||||
doesNotThrow(fn: () => void, msg?: string): void;
|
||||
doesNotThrow(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void;
|
||||
|
||||
/**
|
||||
* Print a message without breaking the tap output.
|
||||
* (Useful when using e.g. tap-colorize where output is buffered & console.log will print in incorrect order vis-a-vis tap output.)
|
||||
*/
|
||||
comment(msg: string): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user