WIP
This commit is contained in:
parent
1c7a31fba2
commit
0d170e4a7a
27
webpack/account/__tests__/request_account_exports.ts
Normal file
27
webpack/account/__tests__/request_account_exports.ts
Normal 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);
|
||||
});
|
||||
});
|
|
@ -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 }) {
|
|
@ -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"];
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue