mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
add power-assert/power-assert.d.ts
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
/// <reference path="./power-assert.d.ts" />
|
||||
|
||||
import assert = require("power-assert");
|
||||
|
||||
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
|
||||
|
||||
assert.deepEqual({ x: { y: 3 } }, { x: { y: 3 } }, "DEEP WENT DERP");
|
||||
assert.deepEqual({x: {y: 3}}, {x: {y: 3}}, "DEEP WENT DERP");
|
||||
|
||||
assert.equal(3, "3", "uses == comparator");
|
||||
|
||||
@@ -17,3 +19,65 @@ assert.doesNotThrow(() => {
|
||||
throw "a hammer at your face";
|
||||
}
|
||||
}, undefined, "What the...*crunch*");
|
||||
|
||||
|
||||
var customizedAssert1 = assert.customize({
|
||||
output: {
|
||||
maxDepth: 2
|
||||
}
|
||||
});
|
||||
|
||||
customizedAssert1(1 + 1 - 2 === 0, "The universe isn't how it should.");
|
||||
|
||||
customizedAssert1.deepEqual({x: {y: 3}}, {x: {y: 3}}, "DEEP WENT DERP");
|
||||
|
||||
customizedAssert1.equal(3, "3", "uses == comparator");
|
||||
|
||||
customizedAssert1.notStrictEqual(2, "2", "uses === comparator");
|
||||
|
||||
customizedAssert1.throws(() => {
|
||||
throw "a hammer at your face";
|
||||
}, undefined, "DODGED IT");
|
||||
|
||||
customizedAssert1.doesNotThrow(() => {
|
||||
if (false) {
|
||||
throw "a hammer at your face";
|
||||
}
|
||||
}, undefined, "What the...*crunch*");
|
||||
|
||||
|
||||
var customizedAssert2 = assert.customize({
|
||||
assertion: {
|
||||
destructive: false,
|
||||
modifyMessageOnRethrow: true,
|
||||
saveContextOnRethrow: true,
|
||||
patterns: [
|
||||
'assert(value, [message])',
|
||||
'assert.ok(value, [message])',
|
||||
'assert.equal(actual, expected, [message])',
|
||||
'assert.notEqual(actual, expected, [message])',
|
||||
'assert.strictEqual(actual, expected, [message])',
|
||||
'assert.notStrictEqual(actual, expected, [message])',
|
||||
'assert.deepEqual(actual, expected, [message])',
|
||||
'assert.notDeepEqual(actual, expected, [message])'
|
||||
]
|
||||
},
|
||||
output: {
|
||||
lineDiffThreshold: 5,
|
||||
maxDepth: 1,
|
||||
anonymous: 'Object',
|
||||
circular: '#@Circular#',
|
||||
lineSeparator: '\n',
|
||||
ambiguousEastAsianCharWidth: 2,
|
||||
widthOf: () => null,
|
||||
stringify: () => null,
|
||||
diff: () => null,
|
||||
writerClass: null,
|
||||
renderers: [
|
||||
'./built-in/file',
|
||||
'./built-in/assertion',
|
||||
'./built-in/diagram',
|
||||
'./built-in/binary-expression'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+10
@@ -5,6 +5,9 @@
|
||||
|
||||
// copy from assert external module in node.d.ts
|
||||
|
||||
/// <reference path="../empower/empower.d.ts" />
|
||||
/// <reference path="../power-assert-formatter/power-assert-formatter.d.ts" />
|
||||
|
||||
declare function assert(value:any, message?:string):void;
|
||||
declare module assert {
|
||||
export class AssertionError implements Error {
|
||||
@@ -49,6 +52,13 @@ declare module assert {
|
||||
};
|
||||
|
||||
export function ifError(value:any):void;
|
||||
|
||||
export interface Options {
|
||||
assertion?: empower.Options;
|
||||
output?: powerAssertFormatter.Options;
|
||||
}
|
||||
|
||||
export function customize(options:Options):typeof assert;
|
||||
}
|
||||
|
||||
declare module "power-assert" {
|
||||
|
||||
Reference in New Issue
Block a user