@khanacademy/wonder-blocks-form 2.2.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/LICENSE +21 -0
- package/dist/es/index.js +1100 -0
- package/dist/index.js +1419 -0
- package/dist/index.js.flow +2 -0
- package/docs.md +1 -0
- package/package.json +35 -0
- package/src/__tests__/__snapshots__/custom-snapshot.test.js.snap +1349 -0
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +6126 -0
- package/src/__tests__/custom-snapshot.test.js +66 -0
- package/src/__tests__/generated-snapshot.test.js +654 -0
- package/src/components/__tests__/checkbox-group.test.js +84 -0
- package/src/components/__tests__/field-heading.test.js +182 -0
- package/src/components/__tests__/labeled-text-field.test.js +442 -0
- package/src/components/__tests__/radio-group.test.js +84 -0
- package/src/components/__tests__/text-field.test.js +424 -0
- package/src/components/checkbox-core.js +201 -0
- package/src/components/checkbox-group.js +161 -0
- package/src/components/checkbox-group.md +200 -0
- package/src/components/checkbox.js +94 -0
- package/src/components/checkbox.md +134 -0
- package/src/components/choice-internal.js +206 -0
- package/src/components/choice.js +104 -0
- package/src/components/field-heading.js +157 -0
- package/src/components/field-heading.md +43 -0
- package/src/components/group-styles.js +35 -0
- package/src/components/labeled-text-field.js +265 -0
- package/src/components/labeled-text-field.md +535 -0
- package/src/components/labeled-text-field.stories.js +359 -0
- package/src/components/radio-core.js +176 -0
- package/src/components/radio-group.js +142 -0
- package/src/components/radio-group.md +129 -0
- package/src/components/radio.js +93 -0
- package/src/components/radio.md +26 -0
- package/src/components/text-field.js +326 -0
- package/src/components/text-field.md +770 -0
- package/src/components/text-field.stories.js +513 -0
- package/src/index.js +18 -0
- package/src/util/types.js +77 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import React from "react";
|
|
3
|
+
import renderer from "react-test-renderer";
|
|
4
|
+
|
|
5
|
+
import CheckboxCore from "../components/checkbox-core.js";
|
|
6
|
+
import RadioCore from "../components/radio-core.js";
|
|
7
|
+
|
|
8
|
+
const states = ["default", "error", "disabled"];
|
|
9
|
+
const clickableStates = ["default", "hovered", "pressed"];
|
|
10
|
+
const checkedStates = [false, true];
|
|
11
|
+
|
|
12
|
+
describe("CheckboxCore", () => {
|
|
13
|
+
states.forEach((state) => {
|
|
14
|
+
clickableStates.forEach((clickableState) => {
|
|
15
|
+
checkedStates.forEach((checked) => {
|
|
16
|
+
test(`type:${state} state:${clickableState} checked:${String(
|
|
17
|
+
checked,
|
|
18
|
+
)}`, () => {
|
|
19
|
+
const disabled = state === "disabled";
|
|
20
|
+
const tree = renderer
|
|
21
|
+
.create(
|
|
22
|
+
<CheckboxCore
|
|
23
|
+
checked={checked}
|
|
24
|
+
disabled={disabled}
|
|
25
|
+
error={state === "error"}
|
|
26
|
+
hovered={clickableState === "hovered"}
|
|
27
|
+
pressed={clickableState === "pressed"}
|
|
28
|
+
focused={clickableState === "focused"}
|
|
29
|
+
waiting={false}
|
|
30
|
+
/>,
|
|
31
|
+
)
|
|
32
|
+
.toJSON();
|
|
33
|
+
expect(tree).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("RadioCore", () => {
|
|
41
|
+
states.forEach((state) => {
|
|
42
|
+
clickableStates.forEach((clickableState) => {
|
|
43
|
+
checkedStates.forEach((checked) => {
|
|
44
|
+
test(`type:${state} state:${clickableState} checked:${String(
|
|
45
|
+
checked,
|
|
46
|
+
)}`, () => {
|
|
47
|
+
const disabled = state === "disabled";
|
|
48
|
+
const tree = renderer
|
|
49
|
+
.create(
|
|
50
|
+
<RadioCore
|
|
51
|
+
checked={checked}
|
|
52
|
+
disabled={disabled}
|
|
53
|
+
error={state === "error"}
|
|
54
|
+
hovered={clickableState === "hovered"}
|
|
55
|
+
pressed={clickableState === "pressed"}
|
|
56
|
+
focused={clickableState === "focused"}
|
|
57
|
+
waiting={false}
|
|
58
|
+
/>,
|
|
59
|
+
)
|
|
60
|
+
.toJSON();
|
|
61
|
+
expect(tree).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|