Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
})
})
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(() => {
const message = wrapper.find(Message)
expect(message.contains(expectedResult)).toBeTruthy()
done()
})
})
})