This commit is contained in:
Rick Carlino 2018-04-30 10:33:41 -05:00
parent 1c7a31fba2
commit 0d170e4a7a
4 changed files with 34 additions and 7 deletions

View file

@ -0,0 +1,27 @@
jest.mock("farmbot-toastr", () => {
return {
success: jest.fn()
};
});
jest.mock("axios", () => {
return {
default: { post: jest.fn(() => Promise.resolve()) }
};
});
import { API } from "../../api";
import { Content } from "../../constants";
import { requestAccountExport } from "../request_account_export";
import { success } from "farmbot-toastr";
import { t } from "i18next";
import axios from "axios";
describe("requestAccountExport", () => {
it("pops toast on completion", () => {
API.setBaseUrl("http://www.foo.bar");
requestAccountExport();
expect(axios.post).toHaveBeenCalledWith(API.current.exportDataPath);
expect(success).toHaveBeenCalledWith(Content.EXPORT_SENT);
});
});

View file

@ -1,6 +1,6 @@
import * as React from "react";
import { Widget, WidgetHeader, WidgetBody, Row, Col } from "../ui";
import { Content } from "../constants";
import { Widget, WidgetHeader, WidgetBody, Row, Col } from "../../ui";
import { Content } from "../../constants";
import { t } from "i18next";
export function ExportAccountPanel(props: { onClick: () => void }) {

View file

@ -11,7 +11,7 @@ import { updateNO } from "../resources/actions";
import { deleteUser } from "./actions";
import { success } from "farmbot-toastr/dist";
import { LabsFeatures } from "./labs/labs_features";
import { ExportAccountPanel } from "./export_account_panel";
import { ExportAccountPanel } from "./components/export_account_panel";
import { requestAccountExport } from "./request_account_export";
const KEYS: (keyof User)[] = ["id", "name", "email", "created_at", "updated_at"];

View file

@ -1,10 +1,10 @@
import { success } from "farmbot-toastr";
import axios from "axios";
import { API } from "../api";
import { t } from "i18next";
import { Content } from "../constants";
import { success } from "farmbot-toastr";
import { t } from "i18next";
import axios from "axios";
const ok = () => success(t(Content.EXPORT_SENT));
export const requestAccountExport =
() => axios.post<void>(API.current.snapshotPath).then(ok);
() => axios.post<void>(API.current.exportDataPath).then(ok);