Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('Get', function() {
afterEach(fetchMock.reset)
afterEach(fetchMock.restore)
beforeEach(function() {
this.api = new Api({
url: API_URL
})
})
afterEach(function() {
this.api = undefined
})
describe('Call with single objId (String)', function() {
beforeEach(function() {
fetchMock.mock(
`begin:${API_URL}/attask/api`,
getFixture,
{
afterEach(() => fetchMock.restore());
after(() => {
fetchMock.restore();
});
afterEach(() => {
fetchMock.restore()
})
async function mock(...args) {
let [response, testFn] = args;
if (args.length === 1) [testFn, response] = [response, { data: { hello: "world" } }];
fetchMock.mock(fakeAPI, response);
await testFn();
fetchMock.restore();
}
beforeEach(() => {
backend.restore();
backend
.mock(APIURL + 'documents/newest', 'GET', {body: JSON.stringify({rows: documents})})
.mock(APIURL + 'documents/relevant', 'GET', {body: JSON.stringify({rows: documents})})
.mock(APIURL + 'templates', 'GET', {body: JSON.stringify({rows: templates})})
.mock(APIURL + 'documents/search?searchTerm=searchTerm', 'GET', {body: JSON.stringify(searchDocuments)});
let params = {};
TestUtils.renderIntoDocument( component = ref} />);
});
beforeEach(() => {
backend.restore();
backend
.get(`${APIURL}entities?sharedId=documentId`, { body: JSON.stringify({ rows: [document] }) })
.get(`${APIURL}relationtypes`, { body: JSON.stringify(relationTypes) })
.get(`${APIURL}references/by_document?sharedId=documentId`, { body: JSON.stringify(references) });
spyOn(relationships, 'requestState').and.returnValue(Promise.resolve(['connectionsGroups', 'searchResults', 'sort']));
});
beforeEach(() => {
backend.restore();
backend
.delete(`${APIURL}thesauris?_id=thesauriId`, { body: JSON.stringify({ testBackendResult: 'ok' }) })
.get(`${APIURL}templates/count_by_thesauri?_id=thesauriWithTemplates`, { body: JSON.stringify(2) })
.get(`${APIURL}templates/count_by_thesauri?_id=thesauriWithoutTemplates`, { body: JSON.stringify(0) });
dispatch = jasmine.createSpy('dispatch');
});
afterEach(() => fetchMock.restore());
afterEach(() => {
fetchMock.restore();
});