@@ -6,11 +6,38 @@ import { Items } from '..';
6
6
7
7
configure ( { adapter : new Adapter ( ) } ) ;
8
8
9
- const items = Object . entries ( {
10
- a : { id : 'a' , val : '10' } ,
11
- b : { id : 'b' , val : '20' } ,
12
- c : { id : 'c' , val : '30' }
13
- } ) ;
9
+ const items = [
10
+ [
11
+ 1 ,
12
+ {
13
+ id : 1 ,
14
+ name : 'Test Product 1' ,
15
+ small_image : '/test/product/1.png' ,
16
+ price : {
17
+ regularPrice : {
18
+ amount : {
19
+ value : 100
20
+ }
21
+ }
22
+ }
23
+ }
24
+ ] ,
25
+ [
26
+ 2 ,
27
+ {
28
+ id : 2 ,
29
+ name : 'Test Product 2' ,
30
+ small_image : '/test/product/2.png' ,
31
+ price : {
32
+ regularPrice : {
33
+ amount : {
34
+ value : 100
35
+ }
36
+ }
37
+ }
38
+ }
39
+ ]
40
+ ] ;
14
41
15
42
test ( 'renders a fragment' , ( ) => {
16
43
const props = { items } ;
@@ -61,7 +88,7 @@ test('passes correct props to each child', () => {
61
88
wrapper . children ( ) . forEach ( ( node , i ) => {
62
89
const [ key , item ] = items [ i ] ;
63
90
64
- expect ( node . key ( ) ) . toEqual ( key ) ;
91
+ expect ( node . key ( ) ) . toEqual ( key . toString ( ) ) ;
65
92
expect ( node . props ( ) ) . toMatchObject ( {
66
93
item,
67
94
render : props . renderItem ,
@@ -158,13 +185,13 @@ test('updates radio `selection` on child click', () => {
158
185
expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( ) ) ;
159
186
160
187
wrapper . childAt ( 0 ) . simulate ( 'click' ) ;
161
- expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 'a' ] ) ) ;
188
+ expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 1 ] ) ) ;
162
189
163
190
wrapper . childAt ( 1 ) . simulate ( 'click' ) ;
164
- expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 'b' ] ) ) ;
191
+ expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 2 ] ) ) ;
165
192
166
193
wrapper . childAt ( 0 ) . simulate ( 'click' ) ;
167
- expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 'a' ] ) ) ;
194
+ expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 1 ] ) ) ;
168
195
} ) ;
169
196
170
197
test ( 'updates checkbox `selection` on child click' , ( ) => {
@@ -174,13 +201,13 @@ test('updates checkbox `selection` on child click', () => {
174
201
expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( ) ) ;
175
202
176
203
wrapper . childAt ( 0 ) . simulate ( 'click' ) ;
177
- expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 'a' ] ) ) ;
204
+ expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 1 ] ) ) ;
178
205
179
206
wrapper . childAt ( 1 ) . simulate ( 'click' ) ;
180
- expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 'a' , 'b' ] ) ) ;
207
+ expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 1 , 2 ] ) ) ;
181
208
182
209
wrapper . childAt ( 0 ) . simulate ( 'click' ) ;
183
- expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 'b' ] ) ) ;
210
+ expect ( wrapper . state ( 'selection' ) ) . toEqual ( new Set ( [ 2 ] ) ) ;
184
211
} ) ;
185
212
186
213
test ( 'calls `syncSelection` after updating selection' , ( ) => {
0 commit comments