add test
parent
8d9cf27e8a
commit
3e231c485c
|
@ -1,6 +1,9 @@
|
|||
jest.mock("../../toast_errors", () => ({ toastErrors: jest.fn() }));
|
||||
|
||||
import { API } from "../../api/api";
|
||||
import * as moxios from "moxios";
|
||||
import { deleteUser, resetAccount } from "../actions";
|
||||
import { toastErrors } from "../../toast_errors";
|
||||
|
||||
describe("deleteUser()", () => {
|
||||
beforeEach(function () {
|
||||
|
@ -60,4 +63,28 @@ describe("deleteUser()", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("errors while resetting an account", (done) => {
|
||||
expect.assertions(3);
|
||||
API.setBaseUrl("http://example.com:80");
|
||||
const thunk = resetAccount({ password: "not Foo!" });
|
||||
const dispatch = jest.fn();
|
||||
const getState = jest.fn();
|
||||
getState.mockImplementation(() => ({ auth: {} }));
|
||||
window.alert = jest.fn();
|
||||
thunk(dispatch, getState);
|
||||
|
||||
moxios.wait(function () {
|
||||
const request = moxios.requests.mostRecent();
|
||||
request.respondWith({
|
||||
status: 422,
|
||||
response: {}
|
||||
}).then(resp => {
|
||||
expect(window.alert).not.toHaveBeenCalled();
|
||||
expect(toastErrors).toHaveBeenCalled();
|
||||
expect(resp.config.url).toContain("api/device/reset");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue