@khanacademy/wonder-blocks-form 4.9.1 → 4.9.3

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/components/checkbox-core.d.ts +2 -2
  3. package/dist/components/checkbox.d.ts +2 -2
  4. package/dist/components/choice-internal.d.ts +2 -2
  5. package/dist/components/choice.d.ts +2 -2
  6. package/dist/components/radio-core.d.ts +2 -2
  7. package/dist/components/radio.d.ts +2 -2
  8. package/dist/components/text-area.d.ts +2 -2
  9. package/dist/components/text-field.d.ts +4 -1
  10. package/dist/es/index.js +31 -78
  11. package/dist/index.js +31 -78
  12. package/package.json +7 -7
  13. package/src/__tests__/__snapshots__/custom-snapshot.test.tsx.snap +0 -247
  14. package/src/__tests__/custom-snapshot.test.tsx +0 -48
  15. package/src/components/__tests__/checkbox-group.test.tsx +0 -162
  16. package/src/components/__tests__/checkbox.test.tsx +0 -138
  17. package/src/components/__tests__/field-heading.test.tsx +0 -225
  18. package/src/components/__tests__/labeled-text-field.test.tsx +0 -727
  19. package/src/components/__tests__/radio-group.test.tsx +0 -182
  20. package/src/components/__tests__/text-area.test.tsx +0 -1286
  21. package/src/components/__tests__/text-field.test.tsx +0 -562
  22. package/src/components/checkbox-core.tsx +0 -239
  23. package/src/components/checkbox-group.tsx +0 -174
  24. package/src/components/checkbox.tsx +0 -99
  25. package/src/components/choice-internal.tsx +0 -184
  26. package/src/components/choice.tsx +0 -157
  27. package/src/components/field-heading.tsx +0 -169
  28. package/src/components/group-styles.ts +0 -33
  29. package/src/components/labeled-text-field.tsx +0 -317
  30. package/src/components/radio-core.tsx +0 -171
  31. package/src/components/radio-group.tsx +0 -159
  32. package/src/components/radio.tsx +0 -82
  33. package/src/components/text-area.tsx +0 -430
  34. package/src/components/text-field.tsx +0 -437
  35. package/src/index.ts +0 -17
  36. package/src/util/types.ts +0 -85
  37. package/tsconfig-build.json +0 -19
  38. package/tsconfig-build.tsbuildinfo +0 -1
@@ -1,225 +0,0 @@
1
- import * as React from "react";
2
- import {render, screen} from "@testing-library/react";
3
- import {StyleSheet} from "aphrodite";
4
-
5
- import {I18nInlineMarkup} from "@khanacademy/wonder-blocks-i18n";
6
- import {Body} from "@khanacademy/wonder-blocks-typography";
7
-
8
- import FieldHeading from "../field-heading";
9
- import TextField from "../text-field";
10
-
11
- describe("FieldHeading", () => {
12
- it("fieldheading renders the label text", () => {
13
- // Arrange
14
- const label = "Label";
15
-
16
- // Act
17
- render(
18
- <FieldHeading
19
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
20
- label={label}
21
- />,
22
- );
23
-
24
- // Assert
25
- expect(screen.getByText(label)).toBeInTheDocument();
26
- });
27
-
28
- it("fieldheading renders the description text", () => {
29
- // Arrange
30
- const description = "Description";
31
-
32
- // Act
33
- render(
34
- <FieldHeading
35
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
36
- label="Label"
37
- description={description}
38
- />,
39
- );
40
-
41
- // Assert
42
- expect(screen.getByText(description)).toBeInTheDocument();
43
- });
44
-
45
- it("fieldheading renders the error text", () => {
46
- // Arrange
47
- const error = "Error";
48
-
49
- // Act
50
- render(
51
- <FieldHeading
52
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
53
- label="Label"
54
- error={error}
55
- />,
56
- );
57
-
58
- // Assert
59
- expect(screen.getByRole("alert")).toBeInTheDocument();
60
- });
61
-
62
- it("fieldheading adds testId to label", () => {
63
- // Arrange
64
- const testId = "testid";
65
-
66
- // Act
67
- render(
68
- <FieldHeading
69
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
70
- label="Label"
71
- testId={testId}
72
- />,
73
- );
74
-
75
- // Assert
76
- const label = screen.getByTestId(`${testId}-label`);
77
- expect(label).toBeInTheDocument();
78
- });
79
-
80
- it("fieldheading adds testId to description", () => {
81
- // Arrange
82
- const testId = "testid";
83
-
84
- // Act
85
- render(
86
- <FieldHeading
87
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
88
- label="Label"
89
- description="Description"
90
- testId={testId}
91
- />,
92
- );
93
-
94
- // Assert
95
- const description = screen.getByTestId(`${testId}-description`);
96
- expect(description).toBeInTheDocument();
97
- });
98
-
99
- it("fieldheading adds testId to error", () => {
100
- // Arrange
101
- const testId = "testid";
102
-
103
- // Act
104
- render(
105
- <FieldHeading
106
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
107
- label="Label"
108
- error="Error"
109
- testId={testId}
110
- />,
111
- );
112
-
113
- // Assert
114
- const error = screen.getByTestId(`${testId}-error`);
115
- expect(error).toBeInTheDocument();
116
- });
117
-
118
- it("fieldheading adds the correctly formatted id to label's htmlFor", () => {
119
- // Arrange
120
- const id = "exampleid";
121
- const testId = "testid";
122
-
123
- // Act
124
- render(
125
- <FieldHeading
126
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
127
- label="Label"
128
- id={id}
129
- testId={testId}
130
- />,
131
- );
132
-
133
- // Assert
134
- const label = screen.getByTestId(`${testId}-label`);
135
- expect(label).toHaveAttribute("for", `${id}-field`);
136
- });
137
-
138
- it("fieldheading adds the correctly formatted id to error's id", () => {
139
- // Arrange
140
- const id = "exampleid";
141
- const testId = "testid";
142
-
143
- // Act
144
- render(
145
- <FieldHeading
146
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
147
- label="Label"
148
- error="Error"
149
- id={id}
150
- testId={testId}
151
- />,
152
- );
153
-
154
- // Assert
155
- const error = screen.getByRole("alert");
156
- expect(error).toHaveAttribute("id", `${id}-error`);
157
- });
158
-
159
- it("stype prop applies to the fieldheading container", () => {
160
- // Arrange
161
- const styles = StyleSheet.create({
162
- style1: {
163
- flexGrow: 1,
164
- background: "blue",
165
- },
166
- });
167
-
168
- // Act
169
- const {container} = render(
170
- <FieldHeading
171
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
172
- label="Label"
173
- error="Error"
174
- style={styles.style1}
175
- />,
176
- );
177
-
178
- // Assert
179
- const fieldHeading = container.childNodes[0];
180
- expect(fieldHeading).toHaveStyle("background: blue");
181
- });
182
-
183
- it("should render a LabelMedium when the 'label' prop is a I18nInlineMarkup", () => {
184
- // Arrange
185
-
186
- // Act
187
- render(
188
- <FieldHeading
189
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
190
- label={
191
- <I18nInlineMarkup b={(s: string) => <b>{s}</b>}>
192
- {"<b>Test</b> Hello, world!"}
193
- </I18nInlineMarkup>
194
- }
195
- />,
196
- );
197
-
198
- // Assert
199
- const label = screen.getByText("Hello, world!");
200
- // LabelMedium has a font-size of 16px
201
- expect(label).toHaveStyle("font-size: 16px");
202
- });
203
-
204
- it("should render a LabelSmall when the 'description' prop is a I18nInlineMarkup", () => {
205
- // Arrange
206
-
207
- // Act
208
- render(
209
- <FieldHeading
210
- field={<TextField id="tf-1" value="" onChange={() => {}} />}
211
- label={<Body>Hello, world</Body>}
212
- description={
213
- <I18nInlineMarkup b={(s: string) => <b>{s}</b>}>
214
- {"<b>Test</b> description"}
215
- </I18nInlineMarkup>
216
- }
217
- />,
218
- );
219
-
220
- // Assert
221
- const description = screen.getByText("description");
222
- // LabelSmall has a font-size of 16px
223
- expect(description).toHaveStyle("font-size: 14px");
224
- });
225
- });