How to use the isomorphic-fetch.default.mockImplementation function in isomorphic-fetch

To help you get started, we’ve selected a few isomorphic-fetch 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 artsy / reaction / src / Apps / Loyalty / Containers / Login / __tests__ / index.tsx View on Github external
it("displays an internal error message", done => {
    fetch.mockImplementation(() => Promise.resolve({ status: 500 }))

    const login = TestUtils.renderIntoDocument() as Login

    TestUtils.Simulate.submit(TestUtils.findRenderedDOMComponentWithTag(login, "form"))

    // Wait till the next event loop tick to assert on the expected DOM state,
    // because `setState` isn’t going to re-render until the next tick either.
    setImmediate(() => {
      const error = TestUtils.findRenderedDOMComponentWithClass(login, "error")
      expect(error.textContent).toBe("Internal Error. Please contact support@artsy.net")
      done()
    })
  })
github artsy / reaction / src / Apps / Loyalty / Containers / ForgotPassword / __tests__ / index.tsx View on Github external
it("displays correct message on failure", done => {
    fetch.mockImplementation(() => Promise.resolve({ status: 400 }))

    const expectedResult = <span>No account exists for <b>test@artsymail.com</b></span>
    const wrapper = shallow()
    wrapper.setState({ email: "test@artsymail.com" })
    const button = wrapper.find(Button)
    button.simulate("click")

    setImmediate(() =&gt; {
      const message = wrapper.find(Message)
      expect(message.contains(expectedResult)).toBeTruthy()
      done()
    })
  })
})