本文整理汇总了TypeScript中nock.disableNetConnect函数的典型用法代码示例。如果您正苦于以下问题:TypeScript disableNetConnect函数的具体用法?TypeScript disableNetConnect怎么用?TypeScript disableNetConnect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了disableNetConnect函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
nock.cleanAll();
nock.disableNetConnect();
const google = new GoogleApis();
localDrive = google.drive('v2');
localGmail = google.gmail('v1');
});
示例2: beforeEach
beforeEach(() => {
nock.cleanAll();
nock.disableNetConnect();
const google = new GoogleApis();
localPlus = google.plus('v1');
localOauth2 = google.oauth2('v2');
});
示例3: before
before(async () => {
nock.cleanAll();
const google = new GoogleApis();
nock.enableNetConnect();
remoteDrive = await Utils.loadApi(google, 'drive', 'v2');
nock.disableNetConnect();
});
示例4: it
it('should support global request params', async () => {
const google = new GoogleApis();
google.options({params: {myParam: '123'}});
const drive = google.drive('v2');
nock(Utils.baseUrl).get('/drive/v2/files/123?myParam=123').reply(200);
const res = await drive.files.get({fileId: '123'});
// If the default param handling is broken, query might be undefined, thus
// concealing the assertion message with some generic "cannot call
// .indexOf of undefined"
let query = Utils.getQs(res) || '';
assert.notEqual(
query.indexOf('myParam=123'), -1, 'Default param not found in query');
// I can't explain why, but the `nock.enableNetConnect()` call below simply
// won't work unless I call `nock.cleanAll()` first.
nock.cleanAll();
nock.enableNetConnect();
const d = await Utils.loadApi(google, 'drive', 'v2');
nock.disableNetConnect();
nock(Utils.baseUrl).get('/drive/v2/files/123?myParam=123').reply(200);
// tslint:disable-next-line no-any
const res3 = await (d as any).files.get({fileId: '123'});
// If the default param handling is broken, query might be undefined,
// thus concealing the assertion message with some generic "cannot
// call .indexOf of undefined"
query = Utils.getQs(res3) || '';
assert.notEqual(
query.indexOf('myParam=123'), -1, 'Default param not found in query');
});
示例5: it
it('should support default params', async () => {
const google = new GoogleApis();
const datastore = google.datastore({
version: 'v1',
params: {myParam: '123'},
});
createNock('myParam=123');
const res = await datastore.projects.lookup({projectId: 'test-project-id'});
// If the default param handling is broken, query might be undefined, thus
// concealing the assertion message with some generic "cannot call .indexOf
// of undefined"
const query = Utils.getQs(res) || '';
assert.notStrictEqual(
query.indexOf('myParam=123'),
-1,
'Default param in query'
);
nock.enableNetConnect();
const datastore2 = await Utils.loadApi(google, 'datastore', 'v1', {
params: {myParam: '123'},
});
nock.disableNetConnect();
createNock('myParam=123');
const res2 =
// tslint:disable-next-line no-any
await (datastore2 as any).projects.lookup({
projectId: 'test-project-id',
});
const query2 = Utils.getQs(res2) || '';
assert.notStrictEqual(
query2.indexOf('myParam=123'),
-1,
'Default param in query'
);
});
示例6: beforeEach
beforeEach(() => {
nock.cleanAll();
nock.disableNetConnect();
const google = new GoogleApis();
localDrive = google.drive('v2');
localUrlshortener = google.urlshortener('v1');
});
示例7: it
it('should allow default params to be overriden per-request', async () => {
const google = new GoogleApis();
const datastore =
google.datastore({version: 'v1', params: {myParam: '123'}});
// Override the default datasetId param for this particular API call
createNock('myParam=456');
const res = await datastore.projects.lookup(
// tslint:disable-next-line no-any
{projectId: 'test-project-id', myParam: '456'} as any);
// If the default param handling is broken, query might be undefined, thus
// concealing the assertion message with some generic "cannot call .indexOf
// of undefined"
const query = Utils.getQs(res) || '';
assert.notEqual(
query.indexOf('myParam=456'), -1, 'Default param not found in query');
nock.enableNetConnect();
const datastore2 = await Utils.loadApi(
google, 'datastore', 'v1', {params: {myParam: '123'}});
nock.disableNetConnect();
// Override the default datasetId param for this particular API call
createNock('myParam=456');
// tslint:disable-next-line no-any
const res2 = await (datastore2 as any).projects.lookup({
projectId: 'test-project-id',
myParam: '456'
});
// If the default param handling is broken, query might be undefined,
// thus concealing the assertion message with some generic "cannot
// call .indexOf of undefined"
const query2 = Utils.getQs(res2) || '';
assert.notEqual(
query2.indexOf('myParam=456'), -1, 'Default param not found in query');
});
示例8: before
before(async () => {
nock.cleanAll();
const google = new GoogleApis();
nock.enableNetConnect();
remoteUrlshortener = await Utils.loadApi(google, 'urlshortener', 'v1');
nock.disableNetConnect();
});
示例9: before
before(async () => {
nock.cleanAll();
const google = new GoogleApis();
nock.enableNetConnect();
[remoteDrive, remoteGmail] = await Promise.all([
Utils.loadApi(google, 'drive', 'v2'), Utils.loadApi(google, 'gmail', 'v1')
]);
nock.disableNetConnect();
});
示例10: before
before(async () => {
nock.cleanAll();
const google = new GoogleApis();
nock.enableNetConnect();
[remotePlus, remoteOauth2] = await Promise.all([
Utils.loadApi(google, 'plus', 'v1'), Utils.loadApi(google, 'oauth2', 'v2')
]);
nock.disableNetConnect();
});