@stackoverflow/stacks 1.10.1 → 1.10.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 (35) hide show
  1. package/dist/css/stacks.css +3 -1
  2. package/dist/css/stacks.min.css +1 -1
  3. package/dist/js/stacks.js +266 -110
  4. package/dist/js/stacks.min.js +1 -1
  5. package/lib/components/activity-indicator/activity-indicator.a11y.test.ts +7 -5
  6. package/lib/components/anchor/anchor.a11y.test.ts +10 -3
  7. package/lib/components/badge/badge.a11y.test.ts +160 -0
  8. package/lib/components/badge/badge.visual.test.ts +150 -0
  9. package/lib/components/banner/banner.a11y.test.ts +14 -0
  10. package/lib/components/block-link/block-link.a11y.test.ts +9 -2
  11. package/lib/components/breadcrumbs/breadcrumbs.a11y.test.ts +2 -0
  12. package/lib/components/button/button.a11y.test.ts +132 -1
  13. package/lib/components/card/card.a11y.test.ts +6 -0
  14. package/lib/components/check-control/check-control.a11y.test.ts +48 -0
  15. package/lib/components/check-control/check-control.visual.test.ts +38 -0
  16. package/lib/components/check-group/check-group.a11y.test.ts +51 -0
  17. package/lib/components/check-group/check-group.visual.test.ts +58 -0
  18. package/lib/components/checkbox_radio/checkbox_radio.a11y.test.ts +39 -0
  19. package/lib/components/checkbox_radio/checkbox_radio.visual.test.ts +35 -0
  20. package/lib/components/description/description.a11y.test.ts +34 -0
  21. package/lib/components/description/description.visual.test.ts +30 -0
  22. package/lib/components/link/link.a11y.test.ts +19 -6
  23. package/lib/components/toggle-switch/toggle-switch.a11y.test.ts +76 -0
  24. package/lib/components/toggle-switch/toggle-switch.less +2 -1
  25. package/lib/components/toggle-switch/toggle-switch.visual.test.ts +74 -0
  26. package/lib/components/uploader/uploader.ts +1 -0
  27. package/lib/test/axe-apca/README.md +34 -0
  28. package/lib/test/axe-apca/index.ts +3 -0
  29. package/lib/test/axe-apca/package.wip.json +30 -0
  30. package/lib/test/axe-apca/src/apca-w3.d.ts +3 -0
  31. package/lib/test/axe-apca/src/axe-apca.test.ts +155 -0
  32. package/lib/test/axe-apca/src/axe-apca.ts +212 -0
  33. package/lib/test/test-utils.ts +18 -1
  34. package/lib/tsconfig.json +1 -0
  35. package/package.json +18 -17
@@ -0,0 +1,160 @@
1
+ import { defaultOptions, runComponentTests } from "../../test/test-utils";
2
+ // import { Icons } from "@stackoverflow/stacks-icons";
3
+ import "../../index";
4
+
5
+ const variants = {
6
+ blings: ["gold", "silver", "bronze"],
7
+ numbers: ["answered", "bounty", "important", "rep", "rep-down", "votes"],
8
+ states: {
9
+ filled: ["danger", "muted"],
10
+ other: ["info", "warning"],
11
+ },
12
+ users: ["admin", "moderator", "staff"],
13
+ };
14
+
15
+ describe("badge", () => {
16
+ // Award badges (Default/badge counts)
17
+ variants.blings.map((bling) => {
18
+ runComponentTests({
19
+ type: "a11y",
20
+ baseClass: "s-badge",
21
+ variants: [bling],
22
+ children: {
23
+ default: `<span class="s-award-bling s-award-bling__${bling}">
24
+ Altruist
25
+ </span>`,
26
+ },
27
+ tag: "span",
28
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
29
+ skippedTestids: [
30
+ "s-badge-dark",
31
+ "s-badge-dark-gold",
32
+ "s-badge-dark",
33
+ "s-badge-dark-silver",
34
+ "s-badge-dark",
35
+ "s-badge-dark-bronze",
36
+ ],
37
+ });
38
+ });
39
+
40
+ // Number counts
41
+ runComponentTests({
42
+ type: "a11y",
43
+ baseClass: "s-badge",
44
+ variants: variants.numbers,
45
+ children: {
46
+ default: "123",
47
+ },
48
+ options: {
49
+ ...defaultOptions,
50
+ includeNullModifier: false,
51
+ },
52
+ tag: "span",
53
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
54
+ skippedTestids: [
55
+ "s-badge-dark-answered",
56
+ "s-badge-dark-important",
57
+ "s-badge-dark-rep-down",
58
+ "s-badge-light-answered",
59
+ "s-badge-light-rep",
60
+ "s-badge-dark",
61
+ "s-badge-dark-bounty",
62
+ "s-badge-dark-rep",
63
+ "s-badge-dark-votes",
64
+ "s-badge-light-rep-down",
65
+ ],
66
+ });
67
+
68
+ // Icon badges
69
+ runComponentTests({
70
+ type: "a11y",
71
+ baseClass: "s-badge",
72
+ variants: [...variants.states.filled, ...variants.states.other],
73
+ modifiers: {
74
+ primary: ["icon"],
75
+ },
76
+ children: {
77
+ default: "with icon",
78
+ // icon: Icons.IconEyeSm, // TODO fix the icon imports
79
+ },
80
+ options: {
81
+ ...defaultOptions,
82
+ includeNullModifier: false,
83
+ },
84
+ tag: "span",
85
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
86
+ skippedTestids: [
87
+ "s-badge-dark-danger-icon",
88
+ "s-badge-dark-icon",
89
+ "s-badge-light-danger-icon",
90
+ "s-badge-light-warning-icon",
91
+ ],
92
+ });
93
+
94
+ // Filled badges
95
+ runComponentTests({
96
+ type: "a11y",
97
+ baseClass: "s-badge",
98
+ variants: variants.states.filled,
99
+ modifiers: {
100
+ primary: ["icon"],
101
+ },
102
+ children: {
103
+ default: "filled",
104
+ // icon: Icons.IconEyeOffSm, // TODO fix the icon imports
105
+ },
106
+ options: {
107
+ ...defaultOptions,
108
+ includeNullModifier: false,
109
+ includeNullVariant: false,
110
+ },
111
+ tag: "span",
112
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
113
+ skippedTestids: [
114
+ "s-badge-dark-danger-icon",
115
+ "s-badge-light-danger-icon",
116
+ ],
117
+ });
118
+
119
+ // User badges
120
+ runComponentTests({
121
+ type: "a11y",
122
+ baseClass: "s-badge",
123
+ variants: variants.users,
124
+ modifiers: {
125
+ primary: ["xs", "sm"],
126
+ },
127
+ children: {
128
+ default: "user",
129
+ },
130
+ tag: "span",
131
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
132
+ skippedTestids: [
133
+ /^s-badge-dark-admin.*/,
134
+ "s-badge-dark",
135
+ "s-badge-dark-sm",
136
+ "s-badge-dark-xs",
137
+ "s-badge-light-admin",
138
+ "s-badge-light-admin-sm",
139
+ "s-badge-light-admin-xs",
140
+ "s-badge-light-staff",
141
+ "s-badge-light-staff-sm",
142
+ "s-badge-light-staff-xs",
143
+ ],
144
+ });
145
+
146
+ // Sizes
147
+ runComponentTests({
148
+ type: "a11y",
149
+ baseClass: "s-badge",
150
+ modifiers: {
151
+ primary: ["xs", "sm"],
152
+ },
153
+ children: {
154
+ default: "size badge",
155
+ },
156
+ tag: "span",
157
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
158
+ skippedTestids: ["s-badge-dark", "s-badge-dark-sm", "s-badge-dark-xs"],
159
+ });
160
+ });
@@ -0,0 +1,150 @@
1
+ import { defaultOptions, runComponentTests } from "../../test/test-utils";
2
+ // import { Icons } from "@stackoverflow/stacks-icons";
3
+ import "../../index";
4
+ import { html } from "@open-wc/testing";
5
+
6
+ const variants = {
7
+ blings: ["gold", "silver", "bronze"],
8
+ numbers: ["answered", "bounty", "important", "rep", "rep-down", "votes"],
9
+ states: {
10
+ filled: ["danger", "muted"],
11
+ other: ["info", "warning"],
12
+ },
13
+ users: ["admin", "moderator", "staff"],
14
+ };
15
+
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ const template = ({ component, testid }: any) => html`
18
+ <div
19
+ class="d-inline-flex ai-center jc-center hs1 ws1 p8"
20
+ data-testid="${testid}"
21
+ >
22
+ ${component}
23
+ </div>
24
+ `;
25
+
26
+ describe("badge", () => {
27
+ // Base badge
28
+ runComponentTests({
29
+ type: "visual",
30
+ baseClass: "s-badge",
31
+ children: {
32
+ default: `base badge`,
33
+ },
34
+ tag: "span",
35
+ template,
36
+ });
37
+
38
+ // Award badges
39
+ variants.blings.map((bling) => {
40
+ runComponentTests({
41
+ type: "visual",
42
+ baseClass: "s-badge",
43
+ variants: [bling],
44
+ children: {
45
+ default: `<span class="s-award-bling s-award-bling__${bling}">
46
+ with bling
47
+ </span>`,
48
+ },
49
+ options: {
50
+ ...defaultOptions,
51
+ includeNullVariant: false,
52
+ includeNullModifier: false,
53
+ },
54
+ tag: "span",
55
+ template,
56
+ });
57
+ });
58
+
59
+ // Number counts
60
+ runComponentTests({
61
+ type: "visual",
62
+ baseClass: "s-badge",
63
+ variants: variants.numbers,
64
+ children: {
65
+ default: "123",
66
+ },
67
+ options: {
68
+ ...defaultOptions,
69
+ includeNullVariant: false,
70
+ includeNullModifier: false,
71
+ },
72
+ tag: "span",
73
+ template,
74
+ });
75
+
76
+ // Icon badges
77
+ runComponentTests({
78
+ type: "visual",
79
+ baseClass: "s-badge",
80
+ variants: [...variants.states.filled, ...variants.states.other],
81
+ modifiers: {
82
+ primary: ["icon"],
83
+ },
84
+ children: {
85
+ default: "with icon",
86
+ // icon: Icons.IconEyeSm, // TODO fix the icon imports
87
+ },
88
+ options: {
89
+ ...defaultOptions,
90
+ includeNullModifier: false,
91
+ },
92
+ tag: "span",
93
+ template,
94
+ });
95
+
96
+ // Filled badges
97
+ runComponentTests({
98
+ type: "visual",
99
+ baseClass: "s-badge",
100
+ variants: variants.states.filled,
101
+ children: {
102
+ default: "filled",
103
+ // icon: Icons.IconEyeOffSm, // TODO fix the icon imports
104
+ },
105
+ options: {
106
+ ...defaultOptions,
107
+ includeNullModifier: false,
108
+ includeNullVariant: false,
109
+ },
110
+ tag: "span",
111
+ template,
112
+ });
113
+
114
+ // User badges
115
+ runComponentTests({
116
+ type: "visual",
117
+ baseClass: "s-badge",
118
+ variants: variants.users,
119
+ modifiers: {
120
+ primary: ["xs", "sm"],
121
+ },
122
+ children: {
123
+ default: "user badge",
124
+ },
125
+ options: {
126
+ ...defaultOptions,
127
+ includeNullVariant: false,
128
+ },
129
+ tag: "span",
130
+ template,
131
+ });
132
+
133
+ // Sizes
134
+ runComponentTests({
135
+ type: "visual",
136
+ baseClass: "s-badge",
137
+ modifiers: {
138
+ primary: ["xs", "sm"],
139
+ },
140
+ children: {
141
+ default: "size badge",
142
+ },
143
+ options: {
144
+ ...defaultOptions,
145
+ includeNullModifier: false,
146
+ },
147
+ tag: "span",
148
+ template,
149
+ });
150
+ });
@@ -33,5 +33,19 @@ describe("banner", () => {
33
33
  children: {
34
34
  default: bannerChild,
35
35
  },
36
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
37
+ skippedTestids: [
38
+ "s-banner-dark",
39
+ "s-banner-dark-danger",
40
+ "s-banner-dark-danger-important",
41
+ "s-banner-dark-important",
42
+ "s-banner-dark-info",
43
+ "s-banner-dark-success",
44
+ "s-banner-dark-success-important",
45
+ "s-banner-dark-warning",
46
+ "s-banner-dark-warning-important",
47
+ "s-banner-light-success-important",
48
+ "s-banner-light-warning-important",
49
+ ],
36
50
  });
37
51
  });
@@ -23,6 +23,8 @@ describe("block-link", () => {
23
23
  default: `block link`,
24
24
  },
25
25
  template: blockLinkTemplate,
26
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
27
+ skippedTestids: ["s-block-link-dark"],
26
28
  });
27
29
 
28
30
  // Base + danger
@@ -39,8 +41,12 @@ describe("block-link", () => {
39
41
  ...defaultOptions,
40
42
  includeNullModifier: false,
41
43
  },
42
- skippedTestids: ["s-block-link-dark-danger"],
43
44
  template: blockLinkTemplate,
45
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
46
+ skippedTestids: [
47
+ "s-block-link-dark-danger",
48
+ "s-block-link-light-danger",
49
+ ],
44
50
  });
45
51
 
46
52
  // All left and rignt variants
@@ -58,12 +64,13 @@ describe("block-link", () => {
58
64
  ...defaultOptions,
59
65
  includeNullVariant: false,
60
66
  },
67
+ template: blockLinkTemplate,
68
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
61
69
  skippedTestids: [
62
70
  "s-block-link-dark-left-is-selected-danger",
63
71
  "s-block-link-dark-right-is-selected-danger",
64
72
  "s-block-link-light-left-is-selected-danger",
65
73
  "s-block-link-light-right-is-selected-danger",
66
74
  ],
67
- template: blockLinkTemplate,
68
75
  });
69
76
  });
@@ -33,5 +33,7 @@ describe("breadcrumbs", () => {
33
33
  ${component}
34
34
  </div>
35
35
  `,
36
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
37
+ skippedTestids: ["s-breadcrumbs-dark", "s-breadcrumbs-light"],
36
38
  });
37
39
  });
@@ -25,8 +25,139 @@ describe("button", () => {
25
25
  excludedTestids: [
26
26
  /primary-outlined/, // This combination is not supported
27
27
  ],
28
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
28
29
  skippedTestids: [
29
- /s-btn-dark/, // TODO remove when contrast bugs are fixed
30
+ "s-btn-light",
31
+ "s-btn-light-dropdown",
32
+ "s-btn-light-dropdown-is-loading",
33
+ "s-btn-light-icon",
34
+ "s-btn-light-icon-is-loading",
35
+ "s-btn-light-is-loading",
36
+ "s-btn-light-link",
37
+ "s-btn-light-muted-filled",
38
+ "s-btn-light-muted-filled-dropdown",
39
+ "s-btn-light-muted-filled-dropdown-is-loading",
40
+ "s-btn-light-muted-filled-icon",
41
+ "s-btn-light-muted-filled-icon-is-loading",
42
+ "s-btn-light-muted-filled-is-loading",
43
+ "s-btn-light-muted-filled-sm",
44
+ "s-btn-light-muted-filled-sm-is-loading",
45
+ "s-btn-light-muted-filled-xs",
46
+ "s-btn-light-muted-filled-xs-is-loading",
47
+ "s-btn-light-outlined",
48
+ "s-btn-light-outlined-dropdown",
49
+ "s-btn-light-outlined-dropdown-is-loading",
50
+ "s-btn-light-outlined-icon",
51
+ "s-btn-light-outlined-icon-is-loading",
52
+ "s-btn-light-outlined-is-loading",
53
+ "s-btn-light-outlined-sm",
54
+ "s-btn-light-outlined-sm-is-loading",
55
+ "s-btn-light-outlined-xs",
56
+ "s-btn-light-outlined-xs-is-loading",
57
+ "s-btn-light-sm",
58
+ "s-btn-light-sm-is-loading",
59
+ "s-btn-light-xs",
60
+ "s-btn-light-xs-is-loading",
61
+ "s-btn-dark",
62
+ "s-btn-dark-danger",
63
+ "s-btn-dark-danger-dropdown",
64
+ "s-btn-dark-danger-dropdown-is-loading",
65
+ "s-btn-dark-danger-icon",
66
+ "s-btn-dark-danger-icon-is-loading",
67
+ "s-btn-dark-danger-is-loading",
68
+ "s-btn-dark-danger-md",
69
+ "s-btn-dark-danger-md-is-loading",
70
+ "s-btn-dark-danger-outlined",
71
+ "s-btn-dark-danger-outlined-dropdown",
72
+ "s-btn-dark-danger-outlined-dropdown-is-loading",
73
+ "s-btn-dark-danger-outlined-icon",
74
+ "s-btn-dark-danger-outlined-icon-is-loading",
75
+ "s-btn-dark-danger-outlined-is-loading",
76
+ "s-btn-dark-danger-outlined-md",
77
+ "s-btn-dark-danger-outlined-md-is-loading",
78
+ "s-btn-dark-danger-outlined-sm",
79
+ "s-btn-dark-danger-outlined-sm-is-loading",
80
+ "s-btn-dark-danger-outlined-xs",
81
+ "s-btn-dark-danger-outlined-xs-is-loading",
82
+ "s-btn-dark-danger-sm",
83
+ "s-btn-dark-danger-sm-is-loading",
84
+ "s-btn-dark-danger-xs",
85
+ "s-btn-dark-danger-xs-is-loading",
86
+ "s-btn-dark-dropdown",
87
+ "s-btn-dark-dropdown-is-loading",
88
+ "s-btn-dark-filled",
89
+ "s-btn-dark-filled-dropdown",
90
+ "s-btn-dark-filled-dropdown-is-loading",
91
+ "s-btn-dark-filled-icon",
92
+ "s-btn-dark-filled-icon-is-loading",
93
+ "s-btn-dark-filled-is-loading",
94
+ "s-btn-dark-filled-sm",
95
+ "s-btn-dark-filled-sm-is-loading",
96
+ "s-btn-dark-filled-xs",
97
+ "s-btn-dark-filled-xs-is-loading",
98
+ "s-btn-dark-google",
99
+ "s-btn-dark-icon",
100
+ "s-btn-dark-icon-is-loading",
101
+ "s-btn-dark-is-loading",
102
+ "s-btn-dark-link",
103
+ "s-btn-dark-md",
104
+ "s-btn-dark-md-is-loading",
105
+ "s-btn-dark-muted",
106
+ "s-btn-dark-muted-dropdown",
107
+ "s-btn-dark-muted-dropdown-is-loading",
108
+ "s-btn-dark-muted-filled",
109
+ "s-btn-dark-muted-filled-dropdown",
110
+ "s-btn-dark-muted-filled-dropdown-is-loading",
111
+ "s-btn-dark-muted-filled-icon",
112
+ "s-btn-dark-muted-filled-icon-is-loading",
113
+ "s-btn-dark-muted-filled-is-loading",
114
+ "s-btn-dark-muted-filled-sm",
115
+ "s-btn-dark-muted-filled-sm-is-loading",
116
+ "s-btn-dark-muted-filled-xs",
117
+ "s-btn-dark-muted-filled-xs-is-loading",
118
+ "s-btn-dark-muted-icon",
119
+ "s-btn-dark-muted-icon-is-loading",
120
+ "s-btn-dark-muted-is-loading",
121
+ "s-btn-dark-muted-outlined",
122
+ "s-btn-dark-muted-outlined-dropdown",
123
+ "s-btn-dark-muted-outlined-dropdown-is-loading",
124
+ "s-btn-dark-muted-outlined-icon",
125
+ "s-btn-dark-muted-outlined-icon-is-loading",
126
+ "s-btn-dark-muted-outlined-is-loading",
127
+ "s-btn-dark-muted-outlined-sm",
128
+ "s-btn-dark-muted-outlined-sm-is-loading",
129
+ "s-btn-dark-muted-outlined-xs",
130
+ "s-btn-dark-muted-outlined-xs-is-loading",
131
+ "s-btn-dark-muted-sm",
132
+ "s-btn-dark-muted-sm-is-loading",
133
+ "s-btn-dark-muted-xs",
134
+ "s-btn-dark-muted-xs-is-loading",
135
+ "s-btn-dark-outlined",
136
+ "s-btn-dark-outlined-dropdown",
137
+ "s-btn-dark-outlined-dropdown-is-loading",
138
+ "s-btn-dark-outlined-icon",
139
+ "s-btn-dark-outlined-icon-is-loading",
140
+ "s-btn-dark-outlined-is-loading",
141
+ "s-btn-dark-outlined-md",
142
+ "s-btn-dark-outlined-md-is-loading",
143
+ "s-btn-dark-outlined-sm",
144
+ "s-btn-dark-outlined-sm-is-loading",
145
+ "s-btn-dark-outlined-xs",
146
+ "s-btn-dark-outlined-xs-is-loading",
147
+ "s-btn-dark-primary-filled",
148
+ "s-btn-dark-primary-filled-dropdown",
149
+ "s-btn-dark-primary-filled-dropdown-is-loading",
150
+ "s-btn-dark-primary-filled-icon",
151
+ "s-btn-dark-primary-filled-icon-is-loading",
152
+ "s-btn-dark-primary-filled-is-loading",
153
+ "s-btn-dark-primary-filled-sm",
154
+ "s-btn-dark-primary-filled-sm-is-loading",
155
+ "s-btn-dark-primary-filled-xs",
156
+ "s-btn-dark-primary-filled-xs-is-loading",
157
+ "s-btn-dark-sm",
158
+ "s-btn-dark-sm-is-loading",
159
+ "s-btn-dark-xs",
160
+ "s-btn-dark-xs-is-loading",
30
161
  ],
31
162
  });
32
163
  });
@@ -9,5 +9,11 @@ describe("card", () => {
9
9
  children: {
10
10
  default: `<p>This is a description of the card’s content.</p>`,
11
11
  },
12
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
13
+ skippedTestids: [
14
+ "s-card-dark-muted",
15
+ "s-card-light-muted",
16
+ "s-card-highcontrast-light-muted",
17
+ ],
12
18
  });
13
19
  });
@@ -0,0 +1,48 @@
1
+ import { defaultOptions, runComponentTests } from "../../test/test-utils";
2
+ import "../../index";
3
+
4
+ ["checkbox", "radio"].forEach((type) => {
5
+ describe("s-check-control", () => {
6
+ // TODO include indeterminate
7
+ ["checked", "unchecked"].forEach((state) => {
8
+ runComponentTests({
9
+ type: "a11y",
10
+ baseClass: "s-check-control",
11
+ modifiers: {
12
+ global: ["has-warning", "has-error", "has-success"],
13
+ },
14
+ children: {
15
+ default: `
16
+ <input
17
+ class="s-${type}"
18
+ type="${type}"
19
+ id="test-input"
20
+ name=""
21
+ ${state === "checked" ? "checked" : ""}/>
22
+ <label class="s-label" for="test-input">
23
+ Label ${type}
24
+ <p class="s-input-message">Description</p>
25
+ </label>
26
+ `,
27
+ },
28
+ options: {
29
+ ...defaultOptions,
30
+ testidSuffix: `${state}-${type}`,
31
+ },
32
+ // TODO: Most of those skipped tests should be fixed by the new Stacks 2.0 palette
33
+ skippedTestids: [
34
+ /^s-check-control-dark-has-error-(checked|unchecked)-(checkbox|radio)$/,
35
+ /^s-check-control-light-has-(success|warning)-(checked|unchecked)-(checkbox|radio)$/,
36
+ "s-check-control-dark-has-success-checked-checkbox",
37
+ "s-check-control-light-has-error-checked-checkbox",
38
+ "s-check-control-dark-has-success-unchecked-checkbox",
39
+ "s-check-control-light-has-error-unchecked-checkbox",
40
+ "s-check-control-dark-has-success-checked-radio",
41
+ "s-check-control-light-has-error-checked-radio",
42
+ "s-check-control-dark-has-success-unchecked-radio",
43
+ "s-check-control-light-has-error-unchecked-radio",
44
+ ],
45
+ });
46
+ });
47
+ });
48
+ });
@@ -0,0 +1,38 @@
1
+ import { defaultOptions, runComponentTests } from "../../test/test-utils";
2
+ import "../../index";
3
+
4
+ ["checkbox", "radio"].forEach((type) => {
5
+ describe("s-check-control", () => {
6
+ // TODO include indeterminate
7
+ ["checked", "unchecked"].forEach((state) => {
8
+ runComponentTests({
9
+ type: "visual",
10
+ baseClass: "s-check-control",
11
+ modifiers: {
12
+ global: ["has-warning", "has-error", "has-success"],
13
+ },
14
+ attributes: {
15
+ class: "bg-black-100 hs1 ws2 p8",
16
+ },
17
+ children: {
18
+ default: `
19
+ <input
20
+ class="s-${type}"
21
+ type="${type}"
22
+ id="test-input"
23
+ name=""
24
+ ${state === "checked" ? "checked" : ""}/>
25
+ <label class="s-label" for="test-input">
26
+ Label ${type}
27
+ <p class="s-input-message">Description</p>
28
+ </label>
29
+ `,
30
+ },
31
+ options: {
32
+ ...defaultOptions,
33
+ testidSuffix: `${state}-${type}`,
34
+ },
35
+ });
36
+ });
37
+ });
38
+ });
@@ -0,0 +1,51 @@
1
+ import { defaultOptions, runComponentTests } from "../../test/test-utils";
2
+ import "../../index";
3
+
4
+ type CheckGroup = "checkbox" | "radio";
5
+ const checkTypes: CheckGroup[] = ["checkbox", "radio"];
6
+
7
+ checkTypes.forEach((type) => {
8
+ describe("s-check-group", () => {
9
+ const checkEls: {
10
+ type: CheckGroup;
11
+ id: string;
12
+ state?: "checked" | "unchecked" | "indeterminate";
13
+ }[] = [
14
+ { type, id: `test-${type}1`, state: "checked" },
15
+ { type, id: `test-${type}2` },
16
+ ];
17
+ runComponentTests({
18
+ type: "a11y",
19
+ tag: "fieldset",
20
+ baseClass: "s-check-group",
21
+ variants: ["horizontal"],
22
+ children: {
23
+ default: `
24
+ <legend class="s-label">${type} group</legend>
25
+ ${checkEls
26
+ .map(
27
+ ({ type, state, id }, index) => `
28
+ <div class="s-check-control">
29
+ <input
30
+ class="s-${type}"
31
+ type="${type}"
32
+ id="${id}-${index}"
33
+ name=""
34
+ ${state === "checked" ? "checked" : ""}/>
35
+ <label class="s-label" for="${id}-${index}">
36
+ ${type} label ${index}
37
+ <p class="s-input-message">Description</p>
38
+ </label>
39
+ </div>
40
+ `
41
+ )
42
+ .join("")}
43
+ `,
44
+ },
45
+ options: {
46
+ ...defaultOptions,
47
+ testidSuffix: type,
48
+ },
49
+ });
50
+ });
51
+ });