Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return this.api.create(objCode, params, fields).then(function() {
const [url, opts] = fetchMock.lastCall('create')
should(url).endWith(objCode + '?fields=' + encodeURIComponent('*,zzz:*'))
should(opts.method).equal('POST')
should(opts.body).equal('{"foo":"bar"}')
})
})
it('should send correct payload with username', async () => {
fetchMock.postOnce(
'https://samples.auth0.com/dbconnections/signup',
success
);
expect.assertions(1);
await auth.createUser({ ...parameters, usename: 'info' });
expect(fetchMock.lastCall()).toMatchSnapshot();
});
return this.api.copy('foo', 'bar', {name: 'Copy of bar'}).then(function() {
const [url, opts] = fetchMock.lastCall('copy')
should(url).endWith('foo')
should(opts.method).equal('POST')
should(opts.body).containEql('updates=' + encodeURIComponent('{"name":"Copy of bar"}'))
should(opts.body).containEql('copySourceID=bar')
should(opts.body).not.containEql('options')
})
})
it('should send correct payload', async () => {
fetchMock.postOnce('https://login.microsoftonline.com/common/oauth2/v2.0/token', tokens)
expect.assertions(1)
await auth.refreshTokens(parameters)
expect(fetchMock.lastCall()).toMatchSnapshot()
})
complete: () => {
try {
let body = convertBatchedBody(fetchMock.lastCall()[1].body);
expect(body.query).toBe(print(sampleMutation));
expect(body.variables).toEqual(variables);
expect(body.context).not.toBeDefined();
if (includeExtensions) {
expect(body.extensions).toBeDefined();
} else {
expect(body.extensions).not.toBeDefined();
}
expect(next).toHaveBeenCalledTimes(1);
after();
} catch (e) {
done.fail(e);
}
},
});
complete: () => {
try {
let body = convertBatchedBody(fetchMock.lastCall()[1].body);
expect(body.query).toBe(print(sampleMutation));
expect(body.variables).toEqual(variables);
expect(body.context).not.toBeDefined();
if (includeExtensions) {
expect(body.extensions).toBeDefined();
} else {
expect(body.extensions).not.toBeDefined();
}
expect(next).toHaveBeenCalledTimes(1);
after();
} catch (e) {
done.fail(e);
}
},
});
it('creates a new thumbnail and return it', async () => {
fetchMock.mock('/api/thumbnails/', {
id: '42',
ready_to_display: false,
urls: null,
});
const thumbnail = await createThumbnail();
const fetchArgs = fetchMock.lastCall()![1]!;
expect(thumbnail).toEqual({
id: '42',
ready_to_display: false,
urls: null,
});
expect(fetchArgs.headers).toEqual({
Authorization: 'Bearer token',
'Content-Type': 'application/json',
});
expect(fetchArgs.method).toEqual('POST');
});
it('should perform a successful httpPost', async () => {
fetchMock.once('end:/post-ok', { success: true });
const res = await httpPost(node, 'post-ok', { data: 'asdf' });
expect(res).toEqual({ success: true });
const lastCall = fetchMock.lastCall() as any;
expect(lastCall).toBeInstanceOf(Array);
expect(lastCall[1].body).toEqual('{"data":"asdf"}');
});
'checked',
false,
);
await act(async () => {
fireEvent.click(getByLabelText('Allow video download'));
return deferred.resolve({ ...video, show_download: true });
});
expect(getByLabelText('Allow video download')).toHaveProperty(
'checked',
true,
);
expect(fetchMock.calls()).toHaveLength(1);
expect(fetchMock.lastCall()![0]).toEqual('/api/videos/442/');
expect(fetchMock.lastCall()![1]!.body).toEqual(
JSON.stringify({
...video,
show_download: true,
}),
);
});
});
nonCatalogServices.forEach(async service => {
const fetcher = createRestFetch({
wait: () => 1,
getAuthToken: () => '1234',
});
fetchMock.mock('path:/v1/test', 200);
await fetcher({ endpoint: '/test', service });
const [, req] = fetchMock.lastCall() as any;
return expect(req.headers).toEqual({ authorization: 'Bearer 1234' });
}));