Remove fastclick, add syncFail tests.
parent
8fd2e71362
commit
e3a2d72abe
|
@ -1,7 +1,3 @@
|
|||
jest.mock("fastclick", () => ({
|
||||
attach: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock("react-redux", () => ({
|
||||
connect: jest.fn()
|
||||
}));
|
||||
|
|
|
@ -10,11 +10,6 @@ jest.mock("../redux/store", () => {
|
|||
return { store: { dispatch: jest.fn() } };
|
||||
});
|
||||
|
||||
jest.mock("fastclick", () => {
|
||||
// Incidental stub. Can be removed if fastclick is ever removed.
|
||||
return { attach: jest.fn() };
|
||||
});
|
||||
|
||||
jest.mock("../config/actions", () => {
|
||||
// Stubbing this to make testing easier.
|
||||
return { ready: () => ({ type: "YES_IT_WAS_CALLED" }) };
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
jest.mock("fastclick", () => ({
|
||||
attach: jest.fn(),
|
||||
}));
|
||||
|
||||
let mockAuth: AuthState | undefined = undefined;
|
||||
jest.mock("../session", () => ({
|
||||
Session: {
|
||||
|
|
|
@ -25,10 +25,6 @@ import { FirmwareConfig } from "farmbot/dist/resources/configs/firmware";
|
|||
import { getFirmwareConfig } from "./resources/getters";
|
||||
import { intersection } from "lodash";
|
||||
|
||||
/** Remove 300ms delay on touch devices - https://github.com/ftlabs/fastclick */
|
||||
// const fastClick = require("fastclick");
|
||||
// fastClick.attach(document.body);
|
||||
|
||||
/** For the logger module */
|
||||
init();
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
jest.mock("../../session", () => ({
|
||||
Session: {
|
||||
clear: jest.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
import { syncFail } from "../actions";
|
||||
import { Session } from "../../session";
|
||||
|
||||
describe("syncFail", () => {
|
||||
it("tells you why you've been logged out", () => {
|
||||
const e = new Error("Whatever");
|
||||
console.error = jest.fn();
|
||||
expect(() => syncFail(e)).toThrowError(e);
|
||||
expect(console.error).toHaveBeenCalledWith("DATA SYNC ERROR!");
|
||||
expect(Session.clear).toHaveBeenCalled();
|
||||
});
|
||||
});
|
|
@ -36,8 +36,8 @@ export const newTaggedResource = <T extends TR>(kind: T["kind"],
|
|||
});
|
||||
};
|
||||
|
||||
function fail(e: Error) {
|
||||
console.error("DATA SYNC ERROR!!");
|
||||
export function syncFail(e: Error) {
|
||||
console.error("DATA SYNC ERROR!");
|
||||
Session.clear();
|
||||
throw e;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ const download = (dispatch: Function) =>
|
|||
.get<T["body"] | T["body"][]>(url)
|
||||
.then(({ data }) => {
|
||||
dispatch(resourceReady(kind, newTaggedResource(kind, data)));
|
||||
}, fail);
|
||||
}, syncFail);
|
||||
|
||||
export async function fetchSyncData(dispatch: Function) {
|
||||
const get = download(dispatch);
|
||||
|
@ -94,5 +94,5 @@ export async function fetchSyncData(dispatch: Function) {
|
|||
]),
|
||||
};
|
||||
const step = (num: keyof typeof group) => group[num];
|
||||
step(0)().then(step(1)).then(step(2)).then(step(3)).then(step(4)).catch(fail);
|
||||
step(0)().then(step(1)).then(step(2)).then(step(3)).then(step(4)).catch(syncFail);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
"@blueprintjs/datetime": "3.5.0",
|
||||
"@blueprintjs/select": "3.4.0",
|
||||
"@types/enzyme": "3.1.15",
|
||||
"@types/fastclick": "1.0.28",
|
||||
"@types/jest": "23.3.12",
|
||||
"@types/lodash": "4.14.120",
|
||||
"@types/markdown-it": "0.0.7",
|
||||
|
@ -46,7 +45,6 @@
|
|||
"enzyme-adapter-react-16": "1.7.1",
|
||||
"farmbot": "7.0.0-rc5",
|
||||
"farmbot-toastr": "1.0.3",
|
||||
"fastclick": "1.0.6",
|
||||
"i18next": "13.1.0",
|
||||
"jest": "23.6.0",
|
||||
"jest-cli": "23.6.0",
|
||||
|
|
Loading…
Reference in New Issue