CEC-4674: add bulk cancel updates (#386)
* add bulk cancel updates * add permission check * remove unused import * make trigger multi-line
This commit is contained in:
committed by
jwu-fisker
parent
b15f0c8bba
commit
27c59878f4
40
src/components/Manifest/Toolbar/actions/Cancel.test.jsx
Normal file
40
src/components/Manifest/Toolbar/actions/Cancel.test.jsx
Normal file
@@ -0,0 +1,40 @@
|
||||
jest.mock("../../../Contexts/UserContext");
|
||||
jest.mock("../../../Contexts/StatusContext");
|
||||
jest.mock("../../../../services/updatesAPI");
|
||||
|
||||
import React from "react";
|
||||
import {
|
||||
render,
|
||||
act,
|
||||
} from "@testing-library/react";
|
||||
import { UserProvider, setToken } from "../../../Contexts/UserContext";
|
||||
import { StatusProvider } from "../../../Contexts/StatusContext";
|
||||
import { TEST_AUTH_OBJECT_FISKER } from "../../../../utils/testing";
|
||||
import Cancel from "./Cancel";
|
||||
import updatesAPI from "../../../../services/updatesAPI";
|
||||
|
||||
describe("Manifest/Cancel", () => {
|
||||
beforeAll(() => {
|
||||
setToken(TEST_AUTH_OBJECT_FISKER);
|
||||
});
|
||||
|
||||
it("makes request to cancel an update", async () => {
|
||||
const api = jest.spyOn(updatesAPI, "cancelCarUpdate");
|
||||
const ref = React.createRef();
|
||||
|
||||
render(
|
||||
<StatusProvider>
|
||||
<UserProvider>
|
||||
<Cancel
|
||||
ref={ref}
|
||||
ids={["1", "2", "3"]}
|
||||
idCSV=""
|
||||
/>
|
||||
</UserProvider>
|
||||
</StatusProvider>
|
||||
);
|
||||
|
||||
await act(async () => ref.current.submit());
|
||||
expect(api).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user