Skip to content

Commit

Permalink
Merge pull request #8 from goodmind/typescript
Browse files Browse the repository at this point in the history
Fix TypeScript definition
  • Loading branch information
goodmind authored Sep 3, 2016
2 parents 9175c71 + 21b4b90 commit 4e729cb
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Jetbrains WebStorm
.idea

# Logs
logs
*.log
Expand Down
15 changes: 1 addition & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import nock = require('nock')
import tape = require('tape')
import tapeNock = require('./modified_tape')

export = tapeNockFactory

declare function tapeNock (name: string, cb: tape.TestCase): void
declare function tapeNock (name: string, opts: tape.TestOptions, cb: tape.TestCase): void
declare function tapeNock (cb: tape.TestCase): void
declare function tapeNock (opts: tape.TestOptions, cb: tape.TestCase): void
declare namespace tapeNock {
export let nock: typeof nock & {
cleanAll: typeof nock.cleanAll
disableNetConnect: typeof nock.disableNetConnect
enableNetConnect: typeof nock.enableNetConnect
recorder: nock.Recorder
}
}

declare function tapeNockFactory (tapeTest: typeof tape, nockOpts: { fixtures: string, mode?: string }): typeof tapeNock
declare namespace tapeNockFactory {}
92 changes: 92 additions & 0 deletions modified_tape.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import nock2 = require('nock')

export = tape

declare function tape(name: string, cb: tape.TestCase): void;
declare function tape(name: string, opts: tape.TestOptions, cb: tape.TestCase): void;
declare function tape(cb: tape.TestCase): void;
declare function tape(opts: tape.TestOptions, cb: tape.TestCase): void;

declare namespace tape {
interface TestCase {
(test: Test): void;
}

interface TestOptions {
skip?: boolean;
timeout?: number;
}

interface StreamOptions {
objectMode?: boolean;
}

export function skip(name: string, cb: tape.TestCase): void;
export function only(name: string, cb: tape.TestCase): void;
export function createHarness(): typeof tape;
export function createStream(opts?: tape.StreamOptions): NodeJS.ReadableStream;

interface Test {
test(name: string, cb: tape.TestCase): void;
plan(n: number): void;
end(err?: any): void;
fail(msg?: string): void;
pass(msg?: string): void;
timeoutAfter(ms: number): void;
skip(msg?: string): void;
ok(value: any, msg?: string): void;
true(value: any, msg?: string): void;
assert(value: any, msg?: string): void;
notOk(value: any, msg?: string): void;
false(value: any, msg?: string): void;
notok(value: any, msg?: string): void;
error(err: any, msg?: string): void;
ifError(err: any, msg?: string): void;
ifErr(err: any, msg?: string): void;
iferror(err: any, msg?: string): void;
equal(a: any, b: any, msg?: string): void;
equals(a: any, b: any, msg?: string): void;
isEqual(a: any, b: any, msg?: string): void;
is(a: any, b: any, msg?: string): void;
strictEqual(a: any, b: any, msg?: string): void;
strictEquals(a: any, b: any, msg?: string): void;
notEqual(a: any, b: any, msg?: string): void;
notEquals(a: any, b: any, msg?: string): void;
notStrictEqual(a: any, b: any, msg?: string): void;
notStrictEquals(a: any, b: any, msg?: string): void;
isNotEqual(a: any, b: any, msg?: string): void;
isNot(a: any, b: any, msg?: string): void;
not(a: any, b: any, msg?: string): void;
doesNotEqual(a: any, b: any, msg?: string): void;
isInequal(a: any, b: any, msg?: string): void;
deepEqual(a: any, b: any, msg?: string): void;
deepEquals(a: any, b: any, msg?: string): void;
isEquivalent(a: any, b: any, msg?: string): void;
same(a: any, b: any, msg?: string): void;
notDeepEqual(a: any, b: any, msg?: string): void;
notEquivalent(a: any, b: any, msg?: string): void;
notDeeply(a: any, b: any, msg?: string): void;
notSame(a: any, b: any, msg?: string): void;
isNotDeepEqual(a: any, b: any, msg?: string): void;
isNotDeeply(a: any, b: any, msg?: string): void;
isNotEquivalent(a: any, b: any, msg?: string): void;
isInequivalent(a: any, b: any, msg?: string): void;
deepLooseEqual(a: any, b: any, msg?: string): void;
looseEqual(a: any, b: any, msg?: string): void;
looseEquals(a: any, b: any, msg?: string): void;
notDeepLooseEqual(a: any, b: any, msg?: string): void;
notLooseEqual(a: any, b: any, msg?: string): void;
notLooseEquals(a: any, b: any, msg?: string): void;
throws(fn: () => void, msg?: string): void;
throws(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void;
doesNotThrow(fn: () => void, msg?: string): void;
doesNotThrow(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void;
comment(msg: string): void;
}
}

// MODIFICATION

declare namespace tape {
export import nock = nock2
}

0 comments on commit 4e729cb

Please sign in to comment.