@thepalaceproject/circulation-admin 1.28.1-post.6 → 1.29.0-post.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { screen, fireEvent } from "@testing-library/react";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
|
|
5
|
+
import CirculationEventsDownload from "../../../src/components/CirculationEventsDownload";
|
|
6
|
+
import { ContextProviderProps } from "../../../src/components/ContextProvider";
|
|
7
|
+
import { FeatureFlags } from "../../../src/interfaces";
|
|
8
|
+
import { defaultFeatureFlags } from "../../../src/utils/featureFlags";
|
|
9
|
+
import { renderWithProviders } from "../testUtils/withProviders";
|
|
10
|
+
|
|
11
|
+
describe("CirculationEventsDownload", () => {
|
|
12
|
+
it("renders nothing if showCircEventsDownload feature flag is false", () => {
|
|
13
|
+
const featureFlags: FeatureFlags = {
|
|
14
|
+
...defaultFeatureFlags,
|
|
15
|
+
showCircEventsDownload: false,
|
|
16
|
+
};
|
|
17
|
+
const contextProviderProps: Partial<ContextProviderProps> = {
|
|
18
|
+
featureFlags,
|
|
19
|
+
};
|
|
20
|
+
const { container } = renderWithProviders(
|
|
21
|
+
<CirculationEventsDownload library="testlib" />,
|
|
22
|
+
{
|
|
23
|
+
contextProviderProps,
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
expect(container).toBeEmptyDOMElement();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("when showCircEventsDownload feature flag is true", () => {
|
|
30
|
+
const featureFlags: FeatureFlags = {
|
|
31
|
+
...defaultFeatureFlags,
|
|
32
|
+
showCircEventsDownload: true,
|
|
33
|
+
};
|
|
34
|
+
const libraryProp = "testlib";
|
|
35
|
+
const contextProviderProps: Partial<ContextProviderProps> = {
|
|
36
|
+
featureFlags,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
renderWithProviders(<CirculationEventsDownload library={libraryProp} />, {
|
|
41
|
+
contextProviderProps,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("renders a download button", () => {
|
|
46
|
+
expect(
|
|
47
|
+
screen.getByRole("button", { name: "Download CSV" })
|
|
48
|
+
).toBeInTheDocument();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("shows the form when the download button is clicked", () => {
|
|
52
|
+
const downloadButton = screen.getByRole("button", {
|
|
53
|
+
name: "Download CSV",
|
|
54
|
+
});
|
|
55
|
+
fireEvent.click(downloadButton);
|
|
56
|
+
expect(
|
|
57
|
+
screen.getByRole("heading", { name: "Download CSV" })
|
|
58
|
+
).toBeInTheDocument();
|
|
59
|
+
expect(
|
|
60
|
+
screen.getByRole("button", { name: "Download" })
|
|
61
|
+
).toBeInTheDocument();
|
|
62
|
+
expect(screen.getByText("Start Date")).toBeInTheDocument();
|
|
63
|
+
expect(screen.getByText("End Date")).toBeInTheDocument();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|