@@ -9,12 +9,16 @@ describe('tablerow', () => {
9
9
const isSelected = jest . fn ( ) ;
10
10
const selectionToggle = jest . fn ( ) ;
11
11
const children = [
12
- < VirtualizedList . Content label = "Id" dataKey = "id" width = { 50 } /> ,
13
- < VirtualizedList . Content label = "Name" dataKey = "name" width = { 350 } /> ,
12
+ < VirtualizedList . Content key = { 0 } label = "Id" dataKey = "id" width = { 50 } /> ,
13
+ < VirtualizedList . Content key = { 1 } label = "Name" dataKey = "name" width = { 350 } /> ,
14
14
] ;
15
15
16
16
// when
17
- const result = insertSelectionConfiguration ( { isSelected, selectionToggle, children } ) ;
17
+ const result = insertSelectionConfiguration ( {
18
+ isSelected,
19
+ selectionToggle,
20
+ children,
21
+ } ) ;
18
22
19
23
// then
20
24
expect ( result ) . toMatchSnapshot ( ) ;
@@ -23,8 +27,8 @@ describe('tablerow', () => {
23
27
it ( 'should NOT insert selection column when selection callback is NOT provided' , ( ) => {
24
28
// given
25
29
const children = [
26
- < VirtualizedList . Content label = "Id" dataKey = "id" width = { 50 } /> ,
27
- < VirtualizedList . Content label = "Name" dataKey = "name" width = { 350 } /> ,
30
+ < VirtualizedList . Content key = { 0 } label = "Id" dataKey = "id" width = { 50 } /> ,
31
+ < VirtualizedList . Content key = { 1 } label = "Name" dataKey = "name" width = { 350 } /> ,
28
32
] ;
29
33
30
34
// when
@@ -33,6 +37,30 @@ describe('tablerow', () => {
33
37
// then
34
38
expect ( result ) . toMatchSnapshot ( ) ;
35
39
} ) ;
40
+ it ( 'should pass selection props to Column' , ( ) => {
41
+ // given
42
+ const isSelected = jest . fn ( ) ;
43
+ const selectionToggle = jest . fn ( ) ;
44
+ const getRowState = jest . fn ( ) ;
45
+ const isToggleAllDisabled = jest . fn ( ) ;
46
+ const children = [
47
+ < VirtualizedList . Content key = { 0 } label = "Id" dataKey = "id" width = { 50 } /> ,
48
+ < VirtualizedList . Content key = { 1 } label = "Name" dataKey = "name" width = { 350 } /> ,
49
+ ] ;
50
+
51
+ // when
52
+ const result = insertSelectionConfiguration ( {
53
+ getRowState,
54
+ isSelected,
55
+ isToggleAllDisabled,
56
+ selectionToggle,
57
+ children,
58
+ } ) ;
59
+
60
+ // then
61
+ expect ( result [ 0 ] . props . columnData . getRowState ) . toBe ( getRowState ) ;
62
+ expect ( result [ 0 ] . props . columnData . isToggleAllDisabled ) . toBe ( isToggleAllDisabled ) ;
63
+ } ) ;
36
64
} ) ;
37
65
38
66
describe ( '#toColumns' , ( ) => {
@@ -41,6 +69,7 @@ describe('tablerow', () => {
41
69
const theme = { header : 'theme-header-classname' } ;
42
70
const children = [
43
71
< VirtualizedList . Content
72
+ key = { 0 }
44
73
label = "Id"
45
74
dataKey = "id"
46
75
headerClassName = "my-header-classname"
@@ -59,7 +88,13 @@ describe('tablerow', () => {
59
88
// given
60
89
const theme = { cell : 'theme-classname' } ;
61
90
const children = [
62
- < VirtualizedList . Content label = "Id" dataKey = "id" className = "my-classname" width = { 50 } /> ,
91
+ < VirtualizedList . Content
92
+ key = { 0 }
93
+ label = "Id"
94
+ dataKey = "id"
95
+ className = "my-classname"
96
+ width = { 50 }
97
+ /> ,
63
98
] ;
64
99
65
100
// when
@@ -74,6 +109,7 @@ describe('tablerow', () => {
74
109
const id = 'my-id' ;
75
110
const children = [
76
111
< VirtualizedList . Content
112
+ key = { 0 }
77
113
label = "Id"
78
114
dataKey = "id"
79
115
columnData = { { custom : 'lol' } }
@@ -92,6 +128,7 @@ describe('tablerow', () => {
92
128
const id = 'my-id' ;
93
129
const children = [
94
130
< VirtualizedList . Content
131
+ key = { 0 }
95
132
label = "Id"
96
133
dataKey = "id"
97
134
columnData = { { custom : 'lol' } }
@@ -113,6 +150,7 @@ describe('tablerow', () => {
113
150
const id = 'my-id' ;
114
151
const children = [
115
152
< VirtualizedList . Content
153
+ key = { 0 }
116
154
label = "Id"
117
155
dataKey = "id"
118
156
columnData = { { custom : 'lol' } }
0 commit comments