mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
Added default assert definition and a second definition for writeFile. Also added a basic test file. Will be expanded more later.
This commit is contained in:
30
node/node-tests.ts
Normal file
30
node/node-tests.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/// <reference path="node.d.ts" />
|
||||
|
||||
import assert = module("assert");
|
||||
import fs = module("fs");
|
||||
|
||||
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
|
||||
|
||||
assert.deepEqual({ x: { y: 3 } }, { x: { y: 3 } }, "DEEP WENT DERP");
|
||||
|
||||
assert.equal(3, "3", "uses == comparator");
|
||||
|
||||
assert.notStrictEqual(2, "2", "uses === comparator");
|
||||
|
||||
assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT");
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
if (false) { throw "a hammer at your face"; }
|
||||
}, undefined, "What the...*crunch*");
|
||||
|
||||
|
||||
fs.writeFile("thebible.txt",
|
||||
"Do unto others as you would have them do unto you.",
|
||||
assert.ifError);
|
||||
|
||||
fs.writeFile("Harry Potter",
|
||||
"\"You be wizzing, Harry,\" jived Dumbledore.",
|
||||
{
|
||||
encoding: "ascii"
|
||||
},
|
||||
assert.ifError);
|
||||
6
node/node.d.ts
vendored
6
node/node.d.ts
vendored
@@ -776,7 +776,8 @@ declare module "fs" {
|
||||
export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void ): void;
|
||||
export function readFileSync(filename: string): NodeBuffer;
|
||||
export function readFileSync(filename: string, encoding: string): string;
|
||||
export function writeFile(filename: string, data: any, encoding?: string, callback?: Function): void;
|
||||
export function writeFile(filename: string, data: any, callback?: (err) => void): void;
|
||||
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: Function): void;
|
||||
export function writeFileSync(filename: string, data: any, encoding?: string): void;
|
||||
export function appendFile(filename: string, data: any, encoding?: string, callback?: Function): void;
|
||||
export function appendFileSync(filename: string, data: any, encoding?: string): void;
|
||||
@@ -1014,6 +1015,7 @@ declare module "util" {
|
||||
}
|
||||
|
||||
declare module "assert" {
|
||||
export function (booleanValue: bool, message?: string);
|
||||
export function fail(actual: any, expected: any, message: string, operator: string): void;
|
||||
export function assert(value: any, message: string): void;
|
||||
export function ok(value: any, message?: string): void;
|
||||
@@ -1054,4 +1056,4 @@ declare module "domain" {
|
||||
export function bind(cb: (er: Error, data: any) =>any): any;
|
||||
export function intercept(cb: (data: any) => any): any;
|
||||
export function dispose(): void;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user