mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
imported 25 definitions from typescript-node-definitions
first batch: the easy pickings - as per https://github.com/borisyankov/DefinitelyTyped/issues/115 - added DT headers (scraped creators from git history) - added tests - some modifications - added CONTRIBUTORS.md for the substantial defs (>50 LOC)
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/// <reference path="nock.d.ts" />
|
||||
|
||||
import nock = require('nock');
|
||||
|
||||
var inst: nock.Scope;
|
||||
var str: string;
|
||||
var bool: boolean;
|
||||
var data: string;
|
||||
var num: number;
|
||||
var value: any;
|
||||
var regex: RegExp;
|
||||
var options: nock.Options;
|
||||
var headers: Object;
|
||||
|
||||
inst = inst.head(str);
|
||||
inst = inst.get(str);
|
||||
inst = inst.get(str, data);
|
||||
inst = inst.post(str);
|
||||
inst = inst.post(str, data);
|
||||
inst = inst.put(str);
|
||||
inst = inst.put(str, data);
|
||||
|
||||
inst = inst.delete(str);
|
||||
inst = inst.delete(str, data);
|
||||
|
||||
inst = inst.intercept(str, str);
|
||||
inst = inst.intercept(str, str, str);
|
||||
inst = inst.intercept(str, str, str, value);
|
||||
|
||||
inst = inst.reply(num);
|
||||
inst = inst.reply(num, str);
|
||||
inst = inst.reply(num, str, headers);
|
||||
inst = inst.reply(num, (uri: string, body: string) => {
|
||||
return str;
|
||||
});
|
||||
inst = inst.reply(num, (uri: string, body: string) => {
|
||||
return str;
|
||||
}, headers);
|
||||
inst = inst.replyWithFile(num, str);
|
||||
|
||||
inst = inst.defaultReplyHeaders(value);
|
||||
inst = inst.matchHeader(str, str);
|
||||
|
||||
inst = inst.filteringPath(regex, str);
|
||||
inst = inst.filteringPath((path: string) => {
|
||||
return str;
|
||||
});
|
||||
inst = inst.filteringRequestBody(regex, str);
|
||||
inst = inst.filteringRequestBody((path: string) => {
|
||||
return str;
|
||||
});
|
||||
|
||||
inst = inst.persist();
|
||||
inst = inst.log(() => {
|
||||
|
||||
});
|
||||
|
||||
inst.done();
|
||||
bool = inst.isDone();
|
||||
inst.restore();
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
// Type definitions for nock
|
||||
// Project: https://github.com/pgte/nock
|
||||
// Definitions by: bonnici <https://github.com/bonnici>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/nock.d.ts
|
||||
|
||||
declare module "nock" {
|
||||
export = nock;
|
||||
|
||||
function nock (host: string, options?: nock.Options): nock.Scope;
|
||||
|
||||
module nock {
|
||||
export function cleanAll(): void;
|
||||
export var recorder: Recorder;
|
||||
|
||||
export interface Scope {
|
||||
get(path: string, data?: string): Scope;
|
||||
post(path: string, data?: string): Scope;
|
||||
put(path: string, data?: string): Scope;
|
||||
head(path: string): Scope;
|
||||
delete(path: string, data?: string): Scope;
|
||||
intercept(path: string, verb: string, body?: string, options?: any): Scope;
|
||||
|
||||
reply(responseCode: number, body?: string, headers?: Object): Scope;
|
||||
reply(responseCode: number, callback: (uri: string, body: string) => string, headers?: Object): Scope;
|
||||
replyWithFile(responseCode: number, fileName: string): Scope;
|
||||
|
||||
defaultReplyHeaders(headers: Object): Scope;
|
||||
matchHeader(name: string, value: string): Scope;
|
||||
|
||||
filteringPath(regex: RegExp, replace: string): Scope;
|
||||
filteringPath(fn: (path: string) => string): Scope;
|
||||
filteringRequestBody(regex: RegExp, replace: string): Scope;
|
||||
filteringRequestBody(fn: (path: string) => string): Scope;
|
||||
|
||||
persist(): Scope;
|
||||
log(out: () => void): Scope;
|
||||
|
||||
done(): void;
|
||||
isDone(): boolean;
|
||||
restore(): void;
|
||||
}
|
||||
|
||||
export interface Recorder {
|
||||
rec(capture?: boolean): void;
|
||||
play(): string[];
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
allowUnmocked?: boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user