@thepalaceproject/circulation-admin 1.42.2-post.9 → 1.43.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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { render, screen, act, fireEvent } from "@testing-library/react";
|
|
3
3
|
import JsonField, { JsonFieldHandle } from "../../../src/components/JsonField";
|
|
4
|
+
import { MONOSPACE_FONT_STACK } from "../../../src/fonts";
|
|
4
5
|
|
|
5
6
|
const setting = {
|
|
6
7
|
key: "my_json",
|
|
@@ -472,6 +473,25 @@ describe("JsonField", () => {
|
|
|
472
473
|
});
|
|
473
474
|
});
|
|
474
475
|
|
|
476
|
+
describe("use_monospace_font", () => {
|
|
477
|
+
(
|
|
478
|
+
[
|
|
479
|
+
{ id: "set", use_monospace_font: true, hasStyle: true },
|
|
480
|
+
{ id: "absent", hasStyle: false },
|
|
481
|
+
] as { id: string; use_monospace_font?: boolean; hasStyle: boolean }[]
|
|
482
|
+
).forEach(({ id, use_monospace_font, hasStyle }) => {
|
|
483
|
+
it(id, () => {
|
|
484
|
+
render(<JsonField setting={{ ...setting, use_monospace_font }} />);
|
|
485
|
+
const ta = screen.getByLabelText("JSON Setting");
|
|
486
|
+
if (hasStyle) {
|
|
487
|
+
expect(ta).toHaveStyle({ fontFamily: MONOSPACE_FONT_STACK });
|
|
488
|
+
} else {
|
|
489
|
+
expect(ta).not.toHaveStyle({ fontFamily: MONOSPACE_FONT_STACK });
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
|
|
475
495
|
describe("clear()", () => {
|
|
476
496
|
it("resets text and clears parse error", () => {
|
|
477
497
|
const ref = React.createRef<JsonFieldHandle>();
|
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { render, screen, fireEvent, act } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import ProtocolFormField from "../../../src/components/ProtocolFormField";
|
|
5
|
+
import { MONOSPACE_FONT_STACK } from "../../../src/fonts";
|
|
5
6
|
|
|
6
7
|
// NB: This file adds / duplicates existing tests from:
|
|
7
8
|
// - `src/components/__tests__/ProtocolFormField-test.tsx`.
|
|
@@ -64,6 +65,41 @@ describe("ProtocolFormField — json type", () => {
|
|
|
64
65
|
});
|
|
65
66
|
});
|
|
66
67
|
|
|
68
|
+
describe("ProtocolFormField — use_monospace_font", () => {
|
|
69
|
+
(
|
|
70
|
+
[
|
|
71
|
+
{ id: "text-input", use_monospace_font: true, hasStyle: true },
|
|
72
|
+
{
|
|
73
|
+
id: "textarea",
|
|
74
|
+
type: "textarea",
|
|
75
|
+
use_monospace_font: true,
|
|
76
|
+
hasStyle: true,
|
|
77
|
+
},
|
|
78
|
+
{ id: "absent", hasStyle: false },
|
|
79
|
+
] as {
|
|
80
|
+
id: string;
|
|
81
|
+
type?: string;
|
|
82
|
+
use_monospace_font?: boolean;
|
|
83
|
+
hasStyle: boolean;
|
|
84
|
+
}[]
|
|
85
|
+
).forEach(({ id, type, use_monospace_font, hasStyle }) => {
|
|
86
|
+
it(id, () => {
|
|
87
|
+
render(
|
|
88
|
+
<ProtocolFormField
|
|
89
|
+
setting={{ key: "f", label: "My Field", type, use_monospace_font }}
|
|
90
|
+
disabled={false}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
const el = screen.getByLabelText("My Field");
|
|
94
|
+
if (hasStyle) {
|
|
95
|
+
expect(el).toHaveStyle({ fontFamily: MONOSPACE_FONT_STACK });
|
|
96
|
+
} else {
|
|
97
|
+
expect(el).not.toHaveStyle({ fontFamily: MONOSPACE_FONT_STACK });
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
67
103
|
describe("ProtocolFormField", () => {
|
|
68
104
|
it("renders date-picker setting", async () => {
|
|
69
105
|
const user = userEvent.setup();
|