mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 14:27:04 +00:00
Merge pull request #26905 from paambaati/master
@types/nock Introduce URL as input for nock
This commit is contained in:
Vendored
+5
-2
@@ -1,17 +1,20 @@
|
||||
// Type definitions for nock v9.1.3
|
||||
// Type definitions for nock v9.3.3
|
||||
// Project: https://github.com/node-nock/nock
|
||||
// Definitions by: bonnici <https://github.com/bonnici>
|
||||
// Horiuchi_H <https://github.com/horiuchi>
|
||||
// afharo <https://github.com/afharo>
|
||||
// Matt R. Wilson <https://github.com/mastermatt>
|
||||
// Garanzha Dmitriy <https://github.com/damour>
|
||||
// GP <https://github.com/paambaati>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Url } from 'url';
|
||||
|
||||
export = nock;
|
||||
|
||||
declare function nock(basePath: string | RegExp, options?: nock.Options): nock.Scope;
|
||||
declare function nock(basePath: string | RegExp | Url, options?: nock.Options): nock.Scope;
|
||||
|
||||
declare namespace nock {
|
||||
export function cleanAll(): void;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import nock = require('nock');
|
||||
import * as fs from 'fs';
|
||||
import { URL } from 'url';
|
||||
|
||||
var scope: nock.Scope;
|
||||
var inst: nock.Interceptor;
|
||||
@@ -144,6 +145,11 @@ var couchdb = nock('http://myapp.iriscouch.com')
|
||||
email: 'pedro.teixeira@gmail.com'
|
||||
});
|
||||
|
||||
// Using URL as input
|
||||
var scope = nock(new URL('https://example.org/'))
|
||||
.get('/resource')
|
||||
.reply(200, 'url matched');
|
||||
|
||||
// Specifying hostname
|
||||
var scope = nock('http://www.example.com')
|
||||
.get('/resource')
|
||||
|
||||
Reference in New Issue
Block a user