More tests
This commit is contained in:
parent
dfac5173f3
commit
5be5586aa8
47
webpack/account/__tests__/index_test.tsx
Normal file
47
webpack/account/__tests__/index_test.tsx
Normal file
|
@ -0,0 +1,47 @@
|
|||
jest.mock("react-redux", () => ({
|
||||
connect: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock("farmbot-toastr/dist", () => ({ success: jest.fn() }));
|
||||
|
||||
import * as React from "react";
|
||||
import { fakeState } from "../../__test_support__/fake_state";
|
||||
import { mapStateToProps } from "../state_to_props";
|
||||
import { mount } from "enzyme";
|
||||
import { Account } from "../index";
|
||||
import { edit, save } from "../../api/crud";
|
||||
|
||||
describe("<Account />", () => {
|
||||
it("handles the onChange event - bad input", () => {
|
||||
const props = mapStateToProps(fakeState());
|
||||
props.dispatch = jest.fn();
|
||||
|
||||
const el = mount(<Account {...props} />);
|
||||
expect(() => {
|
||||
(el.instance() as Account).onChange({
|
||||
currentTarget: {
|
||||
name: "foo",
|
||||
value: "bar"
|
||||
}
|
||||
} as any);
|
||||
}).toThrow();
|
||||
(el.instance() as Account).onChange({
|
||||
currentTarget: {
|
||||
name: "email",
|
||||
value: "foo@bar.com"
|
||||
}
|
||||
} as any);
|
||||
expect(props.dispatch).toHaveBeenCalledTimes(1);
|
||||
const expected = edit(props.user, { email: "foo@bar.com" });
|
||||
expect(props.dispatch).toHaveBeenCalledWith(expected);
|
||||
});
|
||||
|
||||
it("triggers the onSave() event", () => {
|
||||
const props = mapStateToProps(fakeState());
|
||||
props.dispatch = jest.fn(() => Promise.resolve({}));
|
||||
const el = mount(<Account {...props} />);
|
||||
|
||||
(el.instance() as Account).onSave();
|
||||
expect(props.dispatch).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
18
webpack/connectivity/__tests__/reducer_test.ts
Normal file
18
webpack/connectivity/__tests__/reducer_test.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { connectivityReducer } from "../reducer";
|
||||
import { networkUp, networkDown } from "../actions";
|
||||
|
||||
describe("connectivityReducer", () => {
|
||||
it("goes up", () => {
|
||||
const state = connectivityReducer(undefined, networkUp());
|
||||
expect(state).toBeDefined();
|
||||
expect(state && state.state).toBe("up");
|
||||
expect(state && state.at).toBeTruthy();
|
||||
});
|
||||
|
||||
it("goes down", () => {
|
||||
const state = connectivityReducer(undefined, networkDown());
|
||||
expect(state).toBeDefined();
|
||||
expect(state && state.state).toBe("down");
|
||||
expect(state && state.at).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -45,6 +45,5 @@ export function diagnose(x: DiagnosisProps) {
|
|||
x.userMQTT,
|
||||
x.botFirmware);
|
||||
const errMsg = TRUTH_TABLE[errorCode] || DiagnosticMessages.MISC;
|
||||
console.log(`Err code ${errorCode} (${errorCode.toString(2)})`);
|
||||
return `${t(errMsg)} (code ${errorCode})`;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import { stopIE, attachToRoot, shortRevision } from "./util";
|
|||
|
||||
stopIE();
|
||||
|
||||
let r = shortRevision();
|
||||
const r = shortRevision();
|
||||
console.log(r);
|
||||
|
||||
detectLanguage().then((config) => {
|
||||
|
|
Loading…
Reference in a new issue