88 * surface and input modes on an iPhone; an omitted value follows the
99 * component's default (`'popover'` or `'touch'`), distinguishable from an
1010 * explicit `'popover'`; `'adaptive'` and `'bottom-sheet'` keep their sheet
11- * meaning with touch modes under a finger; the idiom and motion follow the
12- * touch modes only; the surface equals useAdaptivePresentation's for every
11+ * meaning with touch modes under a finger, the same on every touch device;
12+ * the surface equals useAdaptivePresentation's for every
1313 * value on every device; live pointer changes; the server default and
1414 * hints; the one-moment read
1515 * @position Unit tests of packages/core/src/utils/presentation.ts
@@ -101,8 +101,6 @@ describe('presentation: a caller choice wins over touch defaults', () => {
101101 expect ( resolve ( 'popover' , whenOmitted ) ) . toEqual ( {
102102 surface : 'popover' ,
103103 touchModes : false ,
104- idiom : 'default' ,
105- motion : 'theme' ,
106104 } ) ;
107105 }
108106 } ) ;
@@ -112,27 +110,22 @@ describe('presentation: a caller choice wins over touch defaults', () => {
112110 expect ( resolve ( undefined , 'touch' ) ) . toEqual ( {
113111 surface : 'popover' ,
114112 touchModes : true ,
115- idiom : 'ios' ,
116- motion : 'uikit' ,
117113 } ) ;
118114 // Today's components: omitted is popover.
119115 expect ( resolve ( undefined ) ) . toEqual ( resolve ( 'popover' ) ) ;
120116 expect ( resolve ( undefined , 'popover' ) ) . toEqual ( resolve ( 'popover' ) ) ;
121117 } ) ;
122118
123- it ( 'turns touch modes on under a finger only, and the UIKit idiom on iOS only ' , ( ) => {
119+ it ( 'turns touch modes on under a finger only, the same on every touch device ' , ( ) => {
124120 setDevice ( ANDROID ) ;
125121 expect ( resolve ( undefined , 'touch' ) ) . toEqual ( {
126122 surface : 'popover' ,
127123 touchModes : true ,
128- idiom : 'default' ,
129- motion : 'theme' ,
130124 } ) ;
131125 for ( const desk of [ DESKTOP , MAC_SAFARI ] ) {
132126 setDevice ( desk ) ;
133127 expect ( resolve ( undefined , 'touch' ) ) . toMatchObject ( {
134128 touchModes : false ,
135- idiom : 'default' ,
136129 } ) ;
137130 }
138131 } ) ;
@@ -142,8 +135,6 @@ describe('presentation: a caller choice wins over touch defaults', () => {
142135 expect ( resolve ( 'adaptive' ) ) . toEqual ( {
143136 surface : 'bottom-sheet' ,
144137 touchModes : true ,
145- idiom : 'ios' ,
146- motion : 'uikit' ,
147138 } ) ;
148139 setDevice ( IPAD ) ;
149140 expect ( resolve ( 'adaptive' ) ) . toMatchObject ( {
@@ -181,9 +172,11 @@ describe('presentation: a caller choice wins over touch defaults', () => {
181172 ) ;
182173 expect ( result . current . touchModes ) . toBe ( true ) ;
183174 act ( ( ) => setDevice ( { coarse : false } ) ) ;
184- expect ( result . current ) . toMatchObject ( { touchModes : false , idiom : 'default' } ) ;
175+ // A fine pointer in this context, checked before the claim.
176+ expect ( window . matchMedia ( '(pointer: coarse)' ) . matches ) . toBe ( false ) ;
177+ expect ( result . current ) . toMatchObject ( { touchModes : false } ) ;
185178 act ( ( ) => setDevice ( { coarse : true } ) ) ;
186- expect ( result . current ) . toMatchObject ( { touchModes : true , idiom : 'ios' } ) ;
179+ expect ( result . current ) . toMatchObject ( { touchModes : true } ) ;
187180 } ) ;
188181
189182 it ( 'renders the server default until hydrated, and honours a server hint' , ( ) => {
@@ -196,26 +189,24 @@ describe('presentation: a caller choice wins over touch defaults', () => {
196189 } ) {
197190 const resolved = usePresentation ( presentation , {
198191 whenOmitted : 'touch' ,
199- serverDefault : hint === true ? { idiom : 'ios' , isCompact : true } : { } ,
192+ serverDefault : hint === true ? { isTouch : true , isCompact : true } : { } ,
200193 } ) ;
201- return `${ resolved . surface } /${ String ( resolved . touchModes ) } / ${ resolved . idiom } ` ;
194+ return `${ resolved . surface } /${ String ( resolved . touchModes ) } ` ;
202195 }
203- expect ( renderToString ( createElement ( Probe ) ) ) . toContain (
204- 'popover/false/default' ,
205- ) ;
196+ expect ( renderToString ( createElement ( Probe ) ) ) . toContain ( 'popover/false' ) ;
206197 expect ( renderToString ( createElement ( Probe , { hint : true } ) ) ) . toContain (
207- 'popover/true/ios ' ,
198+ 'popover/true' ,
208199 ) ;
209200 expect (
210201 renderToString (
211202 createElement ( Probe , { presentation : 'adaptive' , hint : true } ) ,
212203 ) ,
213- ) . toContain ( 'bottom-sheet/true/ios ' ) ;
204+ ) . toContain ( 'bottom-sheet/true' ) ;
214205 expect (
215206 renderToString (
216207 createElement ( Probe , { presentation : 'popover' , hint : true } ) ,
217208 ) ,
218- ) . toContain ( 'popover/false/default ' ) ;
209+ ) . toContain ( 'popover/false' ) ;
219210 } ) ;
220211
221212 it ( 'answers at one moment as the hook does, and as the server would with no window' , ( ) => {
@@ -232,8 +223,6 @@ describe('presentation: a caller choice wins over touch defaults', () => {
232223 ) . toEqual ( {
233224 surface : 'popover' ,
234225 touchModes : false ,
235- idiom : 'default' ,
236- motion : 'theme' ,
237226 } ) ;
238227 } ) ;
239228} ) ;
0 commit comments