How to use the fetch-mock.restore function in fetch-mock

To help you get started, we’ve selected a few fetch-mock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Workfront / workfront-api / test / integration / get.spec.ts View on Github external
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,
                {
github grafoojs / grafoo / packages / transport / __tests__ / index.ts View on Github external
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();
}
github huridocs / uwazi / app / react / controllers / Library / specs / Library.spec.js View on Github external
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} />);
  });
github huridocs / uwazi / app / react / Viewer / actions / specs / routeActions.spec.js View on Github external
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']));
  });
github huridocs / uwazi / app / react / Thesauris / actions / specs / thesaurisActions.spec.js View on Github external
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');
    });