How to use the fetch-mock.delete 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 coalescejs / coalesce / tests / acceptance / simple-hierarchy.spec.js View on Github external
expect(newPost.title).to.eq('Updated Title');
    expect(newPost.user).to.eq(user2);
    expect(parentSession.get(newPost).title).to.eq('Updated Title');

    //
    // Destroying
    //
    session = parentSession.child();

    let comment = session.getBy(Comment, { id: 4 });
    session.destroy(comment);

    expect(comment.isDeleted).to.be.true;
    expect(parentSession.get(comment).isDeleted).to.be.false;
    fetchMock.delete('/comments/4', JSON.stringify({}));

    await session.flush();

    expect(parentSession.get(comment).isDeleted).to.be.true;
  });
github Satyam / book-react-redux / test / client / components / projects / project.js View on Github external
it('onDeleteClick', () => {
      fetchMock.delete(API + PID, { pid: PID });
      const store = mockStore(data);
      const props = mapDispatchToProps(store.dispatch);
      expect(props.onDeleteClick).to.be.a('function');
      props.onDeleteClick({ pid: PID });
      return actionExpects(store,
        {
          type: DELETE_PROJECT,
          payload: { pid: PID },
          meta: { asyncAction: REQUEST_SENT },
        },
        {
          type: DELETE_PROJECT,
          payload: { pid: PID },
          meta: { asyncAction: REPLY_RECEIVED },
        },
        action => {
github coalescejs / coalesce / tests / adapter.spec.js View on Github external
beforeEach(function() {
        fetchMock.delete('/posts/1', JSON.stringify({}));
      });
github jpodwys / preact-journal / client / js / actions / index.spec.js View on Github external
it('should set state.entry to undefined, mark state.entries[entryIndex] for deletion, provide a callback to set, and not remove the entry when the network call fails', (done) => {
        fetchMock.delete('/api/entry/0', 500);
        Entry.deleteEntry(el, { id: 0 });

        const firstCallArgs = el.set.args[0];
        expect(firstCallArgs[0].entry).to.be.undefined;
        expect(firstCallArgs[0].entries[0].needsSync).to.be.true;
        expect(firstCallArgs[0].entries[0].deleted).to.be.true;
        expect(firstCallArgs[0].entries[0].text).to.equal('');
        expect(typeof firstCallArgs[1]).to.equal('function');

        setTimeout(() => {
          expect(el.set.calledTwice).to.be.false;
          expect(console.log.calledWith('deleteEntryFailure')).to.be.true;
          done();
        });
      });
github nashdev / jobs / client / companies / actions.spec.js View on Github external
it("removeCompany() - should persist a company removal", async () => {
    fetchMock.delete("/api/companies/1", {
      body: getCompany()
    });

    const expectedActions = [
      {
        type: types.DELETE,
        payload: normalize(getCompany()),
        messages: {
          success: [{ msg: "Successfully deleted your company." }]
        }
      }
    ];

    const store = mockStore({
      companies: {
        byId: {},
github jpodwys / preact-journal / client / js / actions / index.spec.js View on Github external
it('should set state.entry to undefined, mark state.entries[entryIndex] for deletion, provide a callback to set, and remove the correct entry when the network call succeedes', (done) => {
        fetchMock.delete('/api/entry/0', 204);
        Entry.deleteEntry(el, { id: 0 });

        const firstCallArgs = el.set.args[0];
        expect(firstCallArgs[0].entry).to.be.undefined;
        expect(firstCallArgs[0].entries[0].needsSync).to.be.true;
        expect(firstCallArgs[0].entries[0].deleted).to.be.true;
        expect(firstCallArgs[0].entries[0].text).to.equal('');
        expect(typeof firstCallArgs[1]).to.equal('function');

        setTimeout(() => {
          const secondCallArgs = el.set.args[1];
          expect(secondCallArgs[0].entries.length).to.equal(0);
          done();
        });
      });
github jpodwys / preact-journal / client / js / services / index.spec.js View on Github external
it('should call the del endpoint', (done) => {
      fetchMock.delete('/api/entry/1234', 204);
      Entry.del(1234).then(done).catch(done);
    });
github jpodwys / preact-journal / client / js / actions / index.spec.js View on Github external
it('should sync entries from the client to the server when one or more entries has the needsSync flag', (done) => {
        fetchMock.get('/api/entries/sync/1234', {
          status: 200,
          body: {
            entries: [],
            timestamp: 4321
          }
        });
        fetchMock.post('/api/entry', {
          status: 200,
          body: { id: 3 }
        });
        fetchMock.patch('/api/entry/1', 204);
        fetchMock.delete('/api/entry/2', 204);

        el.state.loggedIn = true;
        el.state.timestamp = 1234;
        el.state.entries = [
          { id: 0, date: '2018-01-01', text: 'bogus', newEntry: true, needsSync: true  },
          { id: 1, date: '2017-01-01', text: 'what', needsSync: true },
          { id: 2, deleted: true, needsSync: true },
        ];
        Entry.getEntries(el);
        setTimeout(() => {
          const entries = el.state.entries;
          expect(entries.length).to.equal(2);
          expect(entries[0].id).to.equal(3);
          expect(entries[0].newEntry).to.be.undefined;
          expect(entries[0].needsSync).to.be.undefined;
          expect(entries[1].needsSync).to.be.undefined;
github apache / incubator-superset / superset / assets / spec / javascripts / sqllab / actions / sqlLab_spec.js View on Github external
describe('backend sync', () => {
    const updateTabStateEndpoint = 'glob:*/tabstateview/*';
    fetchMock.put(updateTabStateEndpoint, {});
    fetchMock.delete(updateTabStateEndpoint, {});
    fetchMock.post(updateTabStateEndpoint, JSON.stringify({ id: 1 }));

    const updateTableSchemaEndpoint = 'glob:*/tableschemaview/*';
    fetchMock.put(updateTableSchemaEndpoint, {});
    fetchMock.delete(updateTableSchemaEndpoint, {});
    fetchMock.post(updateTableSchemaEndpoint, JSON.stringify({ id: 1 }));

    const getTableMetadataEndpoint = 'glob:*/superset/table/*';
    fetchMock.get(getTableMetadataEndpoint, {});
    const getExtraTableMetadataEndpoint =
      'glob:*/superset/extra_table_metadata/*';
    fetchMock.get(getExtraTableMetadataEndpoint, {});

    let isFeatureEnabledMock;

    beforeAll(() => {
github Flexget / webui / src / plugins / lists / base / EntryList / InjectEntryDialog.spec.tsx View on Github external
beforeEach(() => {
      fetchMock
        .delete(`glob:/api/${prefix}/1/${itemPrefix}/*`, {})
        .get('/api/tasks', [
          { name: 'task 1' },
          {
            name: 'task 2',
          },
        ])
        .post('/api/tasks/execute', 200)
        .catch();
    });