Skip to content

Commit 14fcf31

Browse files
chore(table): expands test coverage
- fixes up existing tests to use new default props if necessary - adds numerical test, text alignment, visual elements, empty state, loading state, and a test of a smattering of other focus/selected tests for the rows and cells
1 parent af27018 commit 14fcf31

File tree

1 file changed

+108
-23
lines changed

1 file changed

+108
-23
lines changed

components/table/stories/table.test.js

Lines changed: 108 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,31 @@ export const TableGroup = Variants({
133133
hasColumnDividers: true,
134134
},
135135
{
136-
testHeading: "Summary: selected",
136+
testHeading: "Empty state",
137+
rowItems: [],
138+
},
139+
{
140+
testHeading: "Loading state",
141+
isLoading: true,
142+
},
143+
{
144+
testHeading: "Summary and selected rows",
137145
rowItems: ExampleSummarySelectedContent,
138146
},
139147
{
140-
testHeading: "Multi-select: emphasized",
148+
testHeading: "Selection mode: multiple, emphasized",
141149
rowItems: ExampleMultiSelectContent,
150+
isEmphasized: true,
142151
},
143152
{
144-
testHeading: "Multi-select: non-emphasized",
145-
isEmphasized: false,
153+
testHeading: "Selection mode: multiple, non-emphasized",
146154
rowItems: ExampleMultiSelectContent,
147155
},
148156
{
149157
testHeading: "Quiet multi-select: emphasized",
150158
isQuiet: true,
151159
rowItems: ExampleMultiSelectContent,
160+
isEmphasized: true,
152161
},
153162
{
154163
testHeading: "Scrollable",
@@ -230,7 +239,8 @@ export const TableGroup = Variants({
230239
],
231240
},
232241
{
233-
testHeading: "Collapsible: multi-select",
242+
testHeading: "Selection mode: multiple, collapsible",
243+
selectionMode: "multiple",
234244
rowItems: [
235245
{
236246
showCheckbox: true,
@@ -296,60 +306,100 @@ export const TableGroup = Variants({
296306
],
297307
},
298308
{
299-
testHeading: "Thumbnails",
300-
showThumbnails: true,
309+
testHeading: "End-alignment for numerical data",
301310
rowItems: [
302311
{
303-
cellContent: ["Table row alpha", "Test", "2"],
312+
cellContent: ["Pikachu", "Electric", "35"],
313+
textAlignment: {
314+
2: "end"
315+
}
304316
},
305317
{
306-
cellContent: ["Table row bravo", "Test", "28"],
318+
cellContent: ["Charmander", "Fire", "39"],
319+
textAlignment: {
320+
2: "end"
321+
}
307322
},
308323
{
309-
cellContent: [
310-
"Table row charlie. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.",
311-
"Test",
312-
"23",
313-
],
324+
cellContent: ["Mew", "Psychic", "100"],
325+
textAlignment: {
326+
2: "end"
327+
}
328+
},
329+
],
330+
},
331+
{
332+
testHeading: "Visual elements",
333+
rowItems: [
334+
{
335+
cellContent: "Avatar example",
336+
visualElement: "avatar",
314337
},
315338
{
316-
cellContent: ["Table row delta", "Test", "7"],
339+
cellContent: "Icon example",
340+
visualElement: "icon",
341+
},
342+
{
343+
cellContent: "Thumbnail example",
344+
visualElement: "thumbnail",
317345
},
318346
],
319347
},
320348
{
321-
testHeading: "Thumbnail: collapsible",
322-
showThumbnails: true,
349+
testHeading: "Visual elements: collapsible",
323350
rowItems: [
324351
{
325352
cellContent: "Table row alpha",
326353
isCollapsible: true,
327354
isExpanded: true,
328355
tier: 0,
329-
ariaControls: "table-cr-bravo",
356+
ariaControls: "table-cr-bravo table-cr-delta",
330357
id: "table-cr-alpha",
331358
},
332359
{
333360
cellContent:
334-
"Table row bravo. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.",
361+
"Table row bravo. There is actually another collapsed row here that's not visible. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.",
335362
isCollapsible: true,
336363
tier: 1,
337364
ariaControls: "table-cr-charlie",
338365
id: "table-cr-bravo",
366+
visualElement: "avatar",
367+
},
368+
{
369+
cellContent: [
370+
"Table row charlie",
371+
"Default not visible",
372+
"Default not visible",
373+
],
374+
isCollapsible: true,
375+
isHidden: true,
376+
tier: 2,
377+
id: "table-cr-charlie",
378+
},
379+
{
380+
cellContent: "Selected row delta",
381+
isSelected: true,
382+
isCollapsible: true,
383+
isExpanded: true,
384+
tier: 1,
385+
ariaControls: "table-cr-echo table-cr-foxtrot",
386+
id: "table-cr-delta",
387+
visualElement: "icon",
339388
},
340389
{
341-
cellContent: "Table row charlie",
390+
cellContent: "Table row echo",
342391
tier: 2,
343392
isLastTier: true,
344393
isCollapsible: true,
345-
id: "table-cr-charlie",
394+
id: "table-cr-echo",
395+
visualElement: "thumbnail",
346396
},
347397
{
348-
cellContent: "Table row delta",
398+
cellContent: "Table row foxtrot",
349399
tier: 2,
350400
isLastTier: true,
351401
isCollapsible: true,
352-
id: "table-cr-delta",
402+
id: "table-cr-foxtrot",
353403
},
354404
{
355405
cellContent: "Summary row",
@@ -370,5 +420,40 @@ export const TableGroup = Variants({
370420
testHeading: "Body drop target",
371421
isDropTarget: true,
372422
},
423+
{
424+
testHeading: "Focus, selected states for rows and cells",
425+
rowItems: [
426+
{
427+
cellContent: "Focused selected row, no rounded corners",
428+
isFocused: true,
429+
isSelected: true,
430+
},
431+
{
432+
cellContent: "Table row bravo",
433+
},
434+
{
435+
cellContent: "Selected unfocused row, no rounded corners",
436+
isSelected: true,
437+
},
438+
{
439+
cellContent: "Focused unselected row, no rounded corners",
440+
isFocused: true,
441+
},
442+
{
443+
cellContent: ["Table row with a focused cell", "Focused cell", "Unfocused cell"],
444+
cellCustomClasses: {
445+
1: ["is-focused"]
446+
}
447+
},
448+
{
449+
cellContent: "Table row echo",
450+
},
451+
{
452+
cellContent: "Focused selected row, with rounded corners",
453+
isFocused: true,
454+
isSelected: true,
455+
}
456+
],
457+
}
373458
],
374459
});

0 commit comments

Comments
 (0)