@thepalaceproject/circulation-admin 1.24.0-post.5 → 1.25.0-post.1

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
@@ -150,5 +150,5 @@
150
150
  "*.{js,jsx,ts,tsx,css,md}": "prettier --write",
151
151
  "*.{js,css,md}": "prettier --write"
152
152
  },
153
- "version": "1.24.0-post.5"
153
+ "version": "1.25.0-post.1"
154
154
  }
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+ import ProtocolFormField from "../../../src/components/ProtocolFormField";
5
+
6
+ // NB: This file adds / duplicates existing tests from:
7
+ // - `src/components/__tests__/ProtocolFormField-test.tsx`.
8
+ //
9
+ // Those tests should eventually be migrated here and
10
+ // adapted to the Jest/React Testing Library paradigm.
11
+
12
+ describe("ProtocolFormField", () => {
13
+ it("renders date-picker setting", async () => {
14
+ const user = userEvent.setup();
15
+ const emptyValue = "";
16
+ const testDate = "2022-01-01";
17
+ const datePickerLabel = "A date setting field";
18
+ const fieldDescription = "Description of the setting";
19
+ const setting = {
20
+ key: "setting",
21
+ label: datePickerLabel,
22
+ description: `<p>${fieldDescription}</p>`,
23
+ type: "date-picker",
24
+ };
25
+
26
+ render(<ProtocolFormField setting={setting} disabled={false} />);
27
+ const input = screen.getByLabelText(datePickerLabel) as HTMLInputElement;
28
+
29
+ expect(input.value).toBe(emptyValue);
30
+
31
+ // Enter a date.
32
+ await user.click(input);
33
+ await user.keyboard(`${testDate}{enter}`);
34
+
35
+ expect(input.value).toBe(testDate);
36
+ screen.debug();
37
+ });
38
+ });