11
11
*/
12
12
13
13
jest . mock ( '@react-aria/utils/src/scrollIntoView' ) ;
14
- import { act , fireEvent , pointerMap , render , within } from '@react-spectrum/test-utils-internal' ;
14
+ import { act , fireEvent , pointerMap , renderv3 as render , within } from '@react-spectrum/test-utils-internal' ;
15
15
import { Card , CardView , GalleryLayout , GridLayout , WaterfallLayout } from '../' ;
16
16
import { composeStories } from '@storybook/react' ;
17
17
import { Content } from '@react-spectrum/view' ;
18
18
import { Heading , Text } from '@react-spectrum/text' ;
19
19
import { Image } from '@react-spectrum/image' ;
20
- import { Provider } from '@react-spectrum/provider' ;
21
20
import React , { useMemo } from 'react' ;
22
- import scaleMedium from '@adobe/spectrum-css-temp/vars/spectrum-medium-unique.css' ;
23
21
import { scrollIntoView } from '@react-aria/utils' ;
24
22
import * as stories from '../stories/GridCardView.stories' ;
25
- import themeLight from '@adobe/spectrum-css-temp/vars/spectrum-light-unique.css' ;
26
23
import { useCollator } from '@react-aria/i18n' ;
27
24
import userEvent from '@testing-library/user-event' ;
28
25
@@ -31,11 +28,6 @@ let isOldReact = parseInt(React.version, 10) < 18;
31
28
let { falsyItems} = stories ;
32
29
let { FalsyIds} = composeStories ( stories ) ;
33
30
34
- let theme = {
35
- light : themeLight ,
36
- medium : scaleMedium
37
- } ;
38
-
39
31
let defaultItems = [
40
32
{ width : 1001 , height : 381 , src : 'https://i.imgur.com/Z7AzH2c.jpg' , title : 'Title 1' } ,
41
33
{ width : 640 , height : 640 , src : 'https://i.imgur.com/DhygPot.jpg' , title : 'Title 2' } ,
@@ -77,33 +69,30 @@ function StaticCardView(props) {
77
69
let {
78
70
layout = gridLayout ,
79
71
selectionMode = 'multiple' ,
80
- locale = 'en-US' ,
81
72
...otherProps
82
73
} = props ;
83
74
84
75
return (
85
- < Provider theme = { theme } locale = { locale } >
86
- < CardView onSelectionChange = { onSelectionChange } { ...otherProps } selectionMode = { selectionMode } layout = { layout } width = "100%" height = "100%" aria-label = "Test CardView" >
87
- < Card width = { 1001 } height = { 381 } textValue = "Title 1" >
88
- < Image src = "https://i.imgur.com/Z7AzH2c.jpg" />
89
- < Heading > Title 1</ Heading >
90
- < Text slot = "detail" > PNG</ Text >
91
- < Content > Description</ Content >
92
- </ Card >
93
- < Card width = { 640 } height = { 640 } textValue = "Title 1" >
94
- < Image src = "https://i.imgur.com/DhygPot.jpg" />
95
- < Heading > Title 1</ Heading >
96
- < Text slot = "detail" > PNG</ Text >
97
- < Content > Description</ Content >
98
- </ Card >
99
- < Card width = { 182 } height = { 1009 } textValue = "Title 1" >
100
- < Image src = "https://i.imgur.com/L7RTlvI.png" />
101
- < Heading > Title 1</ Heading >
102
- < Text slot = "detail" > PNG</ Text >
103
- < Content > Description</ Content >
104
- </ Card >
105
- </ CardView >
106
- </ Provider >
76
+ < CardView onSelectionChange = { onSelectionChange } { ...otherProps } selectionMode = { selectionMode } layout = { layout } width = "100%" height = "100%" aria-label = "Test CardView" >
77
+ < Card width = { 1001 } height = { 381 } textValue = "Title 1" >
78
+ < Image src = "https://i.imgur.com/Z7AzH2c.jpg" />
79
+ < Heading > Title 1</ Heading >
80
+ < Text slot = "detail" > PNG</ Text >
81
+ < Content > Description</ Content >
82
+ </ Card >
83
+ < Card width = { 640 } height = { 640 } textValue = "Title 1" >
84
+ < Image src = "https://i.imgur.com/DhygPot.jpg" />
85
+ < Heading > Title 1</ Heading >
86
+ < Text slot = "detail" > PNG</ Text >
87
+ < Content > Description</ Content >
88
+ </ Card >
89
+ < Card width = { 182 } height = { 1009 } textValue = "Title 1" >
90
+ < Image src = "https://i.imgur.com/L7RTlvI.png" />
91
+ < Heading > Title 1</ Heading >
92
+ < Text slot = "detail" > PNG</ Text >
93
+ < Content > Description</ Content >
94
+ </ Card >
95
+ </ CardView >
107
96
) ;
108
97
}
109
98
@@ -115,23 +104,20 @@ function DynamicCardView(props) {
115
104
layout = gridLayout ,
116
105
selectionMode = 'multiple' ,
117
106
items = defaultItems ,
118
- locale = 'en-US' ,
119
107
...otherProps
120
108
} = props ;
121
109
122
110
return (
123
- < Provider theme = { theme } locale = { locale } >
124
- < CardView onSelectionChange = { onSelectionChange } { ...otherProps } selectionMode = { selectionMode } items = { items } layout = { layout } width = "100%" height = "100%" aria-label = "Test CardView" >
125
- { ( item ) => (
126
- < Card key = { item . title } textValue = { item . title } width = { item . width } height = { item . height } >
127
- < Image src = { item . src } />
128
- < Heading > { item . title } </ Heading >
129
- < Text slot = "detail" > PNG</ Text >
130
- < Content > Description</ Content >
131
- </ Card >
111
+ < CardView onSelectionChange = { onSelectionChange } { ...otherProps } selectionMode = { selectionMode } items = { items } layout = { layout } width = "100%" height = "100%" aria-label = "Test CardView" >
112
+ { ( item ) => (
113
+ < Card key = { item . title } textValue = { item . title } width = { item . width } height = { item . height } >
114
+ < Image src = { item . src } />
115
+ < Heading > { item . title } </ Heading >
116
+ < Text slot = "detail" > PNG</ Text >
117
+ < Content > Description</ Content >
118
+ </ Card >
132
119
) }
133
- </ CardView >
134
- </ Provider >
120
+ </ CardView >
135
121
) ;
136
122
}
137
123
@@ -225,9 +211,7 @@ describe('CardView', function () {
225
211
${ 'Waterfall layout' } | ${ WaterfallLayout }
226
212
` ( '$Name CardView supports falsy ids' , function ( { layout} ) {
227
213
let tree = render (
228
- < Provider theme = { theme } locale = "en-US" >
229
- < FalsyIds items = { falsyItems } aria-label = "test falsy" layout = { layout } />
230
- </ Provider >
214
+ < FalsyIds items = { falsyItems } aria-label = "test falsy" layout = { layout } />
231
215
) ;
232
216
act ( ( ) => {
233
217
jest . runAllTimers ( ) ;
@@ -394,7 +378,7 @@ describe('CardView', function () {
394
378
${ 'Grid layout' } | ${ GridLayout }
395
379
${ 'Gallery layout' } | ${ GalleryLayout }
396
380
` ( '$Name CardView should move focus via Arrow Left (RTL)' , async function ( { Name, layout} ) {
397
- let tree = render ( < DynamicCardView locale = "ar-AE" layout = { layout } /> ) ;
381
+ let tree = render ( < DynamicCardView layout = { layout } /> , undefined , { locale : 'ar-AE' } ) ;
398
382
act ( ( ) => {
399
383
jest . runAllTimers ( ) ;
400
384
} ) ;
@@ -460,7 +444,7 @@ describe('CardView', function () {
460
444
${ 'Grid layout' } | ${ GridLayout }
461
445
${ 'Gallery layout' } | ${ GalleryLayout }
462
446
` ( '$Name CardView should move focus via Arrow Right (RTL)' , async function ( { Name, layout} ) {
463
- let tree = render ( < DynamicCardView locale = "ar-AE" layout = { layout } /> ) ;
447
+ let tree = render ( < DynamicCardView layout = { layout } /> , undefined , { locale : 'ar-AE' } ) ;
464
448
act ( ( ) => {
465
449
jest . runAllTimers ( ) ;
466
450
} ) ;
@@ -842,7 +826,7 @@ describe('CardView', function () {
842
826
} ) ;
843
827
844
828
it ( 'should move focus via Arrow Left (RTL)' , async function ( ) {
845
- let tree = render ( < DynamicCardView locale = "ar-AE" layout = { WaterfallLayout } /> ) ;
829
+ let tree = render ( < DynamicCardView layout = { WaterfallLayout } /> , undefined , { locale : 'ar-AE' } ) ;
846
830
act ( ( ) => {
847
831
jest . runAllTimers ( ) ;
848
832
} ) ;
@@ -899,7 +883,7 @@ describe('CardView', function () {
899
883
} ) ;
900
884
901
885
it ( 'should move focus via Arrow Right (RTL)' , async function ( ) {
902
- let tree = render ( < DynamicCardView locale = "ar-AE" layout = { WaterfallLayout } /> ) ;
886
+ let tree = render ( < DynamicCardView layout = { WaterfallLayout } /> , undefined , { locale : 'ar-AE' } ) ;
903
887
act ( ( ) => {
904
888
jest . runAllTimers ( ) ;
905
889
} ) ;
0 commit comments