@khanacademy/wonder-blocks-form 3.1.5 → 3.1.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @khanacademy/wonder-blocks-form
2
2
 
3
+ ## 3.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - cfbf454c: Rename `TextFieldInternal` to `TextField` (same with `LabeledTextField`)
8
+ - Updated dependencies [b561425a]
9
+ - Updated dependencies [a566e232]
10
+ - Updated dependencies [d2b21a6e]
11
+ - @khanacademy/wonder-blocks-core@4.6.0
12
+ - @khanacademy/wonder-blocks-clickable@2.4.2
13
+ - @khanacademy/wonder-blocks-icon@1.2.33
14
+ - @khanacademy/wonder-blocks-layout@1.4.13
15
+ - @khanacademy/wonder-blocks-typography@1.1.35
16
+
17
+ ## 3.1.6
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [4c682709]
22
+ - @khanacademy/wonder-blocks-clickable@2.4.1
23
+
3
24
  ## 3.1.5
4
25
 
5
26
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -641,7 +641,7 @@ class RadioGroup extends React.Component {
641
641
  const _excluded = ["id", "type", "value", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
642
642
  const defaultErrorMessage = "This field is required.";
643
643
 
644
- class TextFieldInternal extends React.Component {
644
+ class TextField extends React.Component {
645
645
  constructor(props) {
646
646
  super(props);
647
647
  this.state = {
@@ -762,7 +762,7 @@ class TextFieldInternal extends React.Component {
762
762
 
763
763
  }
764
764
 
765
- TextFieldInternal.defaultProps = {
765
+ TextField.defaultProps = {
766
766
  type: "text",
767
767
  disabled: false,
768
768
  light: false
@@ -817,7 +817,7 @@ const styles$1 = StyleSheet.create({
817
817
  boxShadow: `0px 0px 0px 1px ${Color.red}, 0px 0px 0px 2px ${Color.white}`
818
818
  }
819
819
  });
820
- const TextField = React.forwardRef((props, ref) => React.createElement(TextFieldInternal, _extends({}, props, {
820
+ var TextField$1 = React.forwardRef((props, ref) => React.createElement(TextField, _extends({}, props, {
821
821
  forwardedRef: ref
822
822
  })));
823
823
 
@@ -911,7 +911,7 @@ const styles = StyleSheet.create({
911
911
  }
912
912
  });
913
913
 
914
- class LabeledTextFieldInternal extends React.Component {
914
+ class LabeledTextField extends React.Component {
915
915
  constructor(props) {
916
916
  super(props);
917
917
 
@@ -988,7 +988,7 @@ class LabeledTextFieldInternal extends React.Component {
988
988
  id: uniqueId,
989
989
  testId: testId,
990
990
  style: style,
991
- field: React.createElement(TextField, {
991
+ field: React.createElement(TextField$1, {
992
992
  id: `${uniqueId}-field`,
993
993
  "aria-describedby": ariaDescribedby ? ariaDescribedby : `${uniqueId}-error`,
994
994
  "aria-invalid": this.state.error ? "true" : "false",
@@ -1019,13 +1019,13 @@ class LabeledTextFieldInternal extends React.Component {
1019
1019
 
1020
1020
  }
1021
1021
 
1022
- LabeledTextFieldInternal.defaultProps = {
1022
+ LabeledTextField.defaultProps = {
1023
1023
  type: "text",
1024
1024
  disabled: false,
1025
1025
  light: false
1026
1026
  };
1027
- const LabeledTextField = React.forwardRef((props, ref) => React.createElement(LabeledTextFieldInternal, _extends({}, props, {
1027
+ var labeledTextField = React.forwardRef((props, ref) => React.createElement(LabeledTextField, _extends({}, props, {
1028
1028
  forwardedRef: ref
1029
1029
  })));
1030
1030
 
1031
- export { Checkbox, CheckboxGroup, Choice, LabeledTextField, RadioGroup, TextField };
1031
+ export { Checkbox, CheckboxGroup, Choice, labeledTextField as LabeledTextField, RadioGroup, TextField$1 as TextField };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-form",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "design": "v1",
5
5
  "description": "Form components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -16,19 +16,19 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-clickable": "^2.4.0",
19
+ "@khanacademy/wonder-blocks-clickable": "^2.4.2",
20
20
  "@khanacademy/wonder-blocks-color": "^1.2.0",
21
- "@khanacademy/wonder-blocks-core": "^4.5.0",
22
- "@khanacademy/wonder-blocks-icon": "^1.2.32",
23
- "@khanacademy/wonder-blocks-layout": "^1.4.12",
21
+ "@khanacademy/wonder-blocks-core": "^4.6.0",
22
+ "@khanacademy/wonder-blocks-icon": "^1.2.33",
23
+ "@khanacademy/wonder-blocks-layout": "^1.4.13",
24
24
  "@khanacademy/wonder-blocks-spacing": "^3.0.5",
25
- "@khanacademy/wonder-blocks-typography": "^1.1.34"
25
+ "@khanacademy/wonder-blocks-typography": "^1.1.35"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "aphrodite": "^1.2.5",
29
29
  "react": "16.14.0"
30
30
  },
31
31
  "devDependencies": {
32
- "wb-dev-build-settings": "^0.4.0"
32
+ "wb-dev-build-settings": "^0.5.0"
33
33
  }
34
34
  }
@@ -1,15 +1,10 @@
1
1
  // @flow
2
2
  import * as React from "react";
3
- import {mount} from "enzyme";
4
- import "jest-enzyme";
3
+ import {render, screen} from "@testing-library/react";
5
4
  import {StyleSheet} from "aphrodite";
6
5
 
7
6
  import {I18nInlineMarkup} from "@khanacademy/wonder-blocks-i18n";
8
- import {
9
- Body,
10
- LabelMedium,
11
- LabelSmall,
12
- } from "@khanacademy/wonder-blocks-typography";
7
+ import {Body} from "@khanacademy/wonder-blocks-typography";
13
8
 
14
9
  import FieldHeading from "../field-heading.js";
15
10
  import TextField from "../text-field.js";
@@ -20,7 +15,7 @@ describe("FieldHeading", () => {
20
15
  const label = "Label";
21
16
 
22
17
  // Act
23
- const wrapper = mount(
18
+ render(
24
19
  <FieldHeading
25
20
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
26
21
  label={label}
@@ -28,7 +23,7 @@ describe("FieldHeading", () => {
28
23
  );
29
24
 
30
25
  // Assert
31
- expect(wrapper).toIncludeText(label);
26
+ expect(screen.getByText(label)).toBeInTheDocument();
32
27
  });
33
28
 
34
29
  it("fieldheading renders the description text", () => {
@@ -36,7 +31,7 @@ describe("FieldHeading", () => {
36
31
  const description = "Description";
37
32
 
38
33
  // Act
39
- const wrapper = mount(
34
+ render(
40
35
  <FieldHeading
41
36
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
42
37
  label="Label"
@@ -45,7 +40,7 @@ describe("FieldHeading", () => {
45
40
  );
46
41
 
47
42
  // Assert
48
- expect(wrapper).toIncludeText(description);
43
+ expect(screen.getByText(description)).toBeInTheDocument();
49
44
  });
50
45
 
51
46
  it("fieldheading renders the error text", () => {
@@ -53,7 +48,7 @@ describe("FieldHeading", () => {
53
48
  const error = "Error";
54
49
 
55
50
  // Act
56
- const wrapper = mount(
51
+ render(
57
52
  <FieldHeading
58
53
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
59
54
  label="Label"
@@ -62,7 +57,7 @@ describe("FieldHeading", () => {
62
57
  );
63
58
 
64
59
  // Assert
65
- expect(wrapper).toIncludeText(error);
60
+ expect(screen.getByRole("alert")).toBeInTheDocument();
66
61
  });
67
62
 
68
63
  it("fieldheading adds testId to label", () => {
@@ -70,7 +65,7 @@ describe("FieldHeading", () => {
70
65
  const testId = "testid";
71
66
 
72
67
  // Act
73
- const wrapper = mount(
68
+ render(
74
69
  <FieldHeading
75
70
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
76
71
  label="Label"
@@ -79,8 +74,8 @@ describe("FieldHeading", () => {
79
74
  );
80
75
 
81
76
  // Assert
82
- const label = wrapper.find(`[data-test-id="${testId}-label"]`);
83
- expect(label).toExist();
77
+ const label = screen.getByTestId(`${testId}-label`);
78
+ expect(label).toBeInTheDocument();
84
79
  });
85
80
 
86
81
  it("fieldheading adds testId to description", () => {
@@ -88,7 +83,7 @@ describe("FieldHeading", () => {
88
83
  const testId = "testid";
89
84
 
90
85
  // Act
91
- const wrapper = mount(
86
+ render(
92
87
  <FieldHeading
93
88
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
94
89
  label="Label"
@@ -98,10 +93,8 @@ describe("FieldHeading", () => {
98
93
  );
99
94
 
100
95
  // Assert
101
- const description = wrapper.find(
102
- `[data-test-id="${testId}-description"]`,
103
- );
104
- expect(description).toExist();
96
+ const description = screen.getByTestId(`${testId}-description`);
97
+ expect(description).toBeInTheDocument();
105
98
  });
106
99
 
107
100
  it("fieldheading adds testId to error", () => {
@@ -109,7 +102,7 @@ describe("FieldHeading", () => {
109
102
  const testId = "testid";
110
103
 
111
104
  // Act
112
- const wrapper = mount(
105
+ render(
113
106
  <FieldHeading
114
107
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
115
108
  label="Label"
@@ -119,8 +112,8 @@ describe("FieldHeading", () => {
119
112
  );
120
113
 
121
114
  // Assert
122
- const error = wrapper.find(`[data-test-id="${testId}-error"]`);
123
- expect(error).toExist();
115
+ const error = screen.getByTestId(`${testId}-error`);
116
+ expect(error).toBeInTheDocument();
124
117
  });
125
118
 
126
119
  it("fieldheading adds the correctly formatted id to label's htmlFor", () => {
@@ -129,7 +122,7 @@ describe("FieldHeading", () => {
129
122
  const testId = "testid";
130
123
 
131
124
  // Act
132
- const wrapper = mount(
125
+ render(
133
126
  <FieldHeading
134
127
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
135
128
  label="Label"
@@ -139,8 +132,8 @@ describe("FieldHeading", () => {
139
132
  );
140
133
 
141
134
  // Assert
142
- const label = wrapper.find(`[data-test-id="${testId}-label"]`);
143
- expect(label).toContainMatchingElement(`[htmlFor="${id}-field"]`);
135
+ const label = screen.getByTestId(`${testId}-label`);
136
+ expect(label).toHaveAttribute("for", `${id}-field`);
144
137
  });
145
138
 
146
139
  it("fieldheading adds the correctly formatted id to error's id", () => {
@@ -149,7 +142,7 @@ describe("FieldHeading", () => {
149
142
  const testId = "testid";
150
143
 
151
144
  // Act
152
- const wrapper = mount(
145
+ render(
153
146
  <FieldHeading
154
147
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
155
148
  label="Label"
@@ -160,8 +153,8 @@ describe("FieldHeading", () => {
160
153
  );
161
154
 
162
155
  // Assert
163
- const error = wrapper.find(`[data-test-id="${testId}-error"]`);
164
- expect(error).toContainMatchingElement(`[id="${id}-error"]`);
156
+ const error = screen.getByRole("alert");
157
+ expect(error).toHaveAttribute("id", `${id}-error`);
165
158
  });
166
159
 
167
160
  it("stype prop applies to the fieldheading container", () => {
@@ -174,7 +167,7 @@ describe("FieldHeading", () => {
174
167
  });
175
168
 
176
169
  // Act
177
- const wrapper = mount(
170
+ const {container} = render(
178
171
  <FieldHeading
179
172
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
180
173
  label="Label"
@@ -184,15 +177,15 @@ describe("FieldHeading", () => {
184
177
  );
185
178
 
186
179
  // Assert
187
- const container = wrapper.find("View").at(0);
188
- expect(container).toHaveStyle(styles.style1);
180
+ const fieldHeading = container.childNodes[0];
181
+ expect(fieldHeading).toHaveStyle("background: blue");
189
182
  });
190
183
 
191
- it("should render a LabelSmall when the 'label' prop is a I18nInlineMarkup", () => {
184
+ it("should render a LabelMedium when the 'label' prop is a I18nInlineMarkup", () => {
192
185
  // Arrange
193
186
 
194
187
  // Act
195
- const wrapper = mount(
188
+ render(
196
189
  <FieldHeading
197
190
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
198
191
  label={<I18nInlineMarkup>Hello, world!</I18nInlineMarkup>}
@@ -200,15 +193,16 @@ describe("FieldHeading", () => {
200
193
  );
201
194
 
202
195
  // Assert
203
- const label = wrapper.find(LabelMedium);
204
- expect(label).toExist();
196
+ const label = screen.getByText("Hello, world!");
197
+ // LabelMedium has a font-size of 16px
198
+ expect(label).toHaveStyle("font-size: 16px");
205
199
  });
206
200
 
207
201
  it("should render a LabelSmall when the 'description' prop is a I18nInlineMarkup", () => {
208
202
  // Arrange
209
203
 
210
204
  // Act
211
- const wrapper = mount(
205
+ render(
212
206
  <FieldHeading
213
207
  field={<TextField id="tf-1" value="" onChange={() => {}} />}
214
208
  label={<Body>Hello, world</Body>}
@@ -217,7 +211,8 @@ describe("FieldHeading", () => {
217
211
  );
218
212
 
219
213
  // Assert
220
- const label = wrapper.find(LabelSmall);
221
- expect(label).toExist();
214
+ const description = screen.getByText("description");
215
+ // LabelSmall has a font-size of 16px
216
+ expect(description).toHaveStyle("font-size: 14px");
222
217
  });
223
218
  });