@@ -5,15 +5,7 @@ import {
55} from '@coveo/headless/commerce' ;
66import { html } from 'lit' ;
77import { ifDefined } from 'lit/directives/if-defined.js' ;
8- import {
9- beforeEach ,
10- describe ,
11- expect ,
12- it ,
13- type MockInstance ,
14- test ,
15- vi ,
16- } from 'vitest' ;
8+ import { beforeEach , describe , expect , it , type MockInstance , vi } from 'vitest' ;
179import { page } from 'vitest/browser' ;
1810import { renderInAtomicCommerceInterface } from '@/vitest-utils/testing-helpers/fixtures/atomic/commerce/atomic-commerce-interface-fixture' ;
1911import { buildFakePager } from '@/vitest-utils/testing-helpers/fixtures/headless/commerce/pager-subcontroller' ;
@@ -104,7 +96,7 @@ describe('atomic-commerce-pager', () => {
10496 return element ;
10597 } ;
10698
107- test ( 'should call buildProductListing with engine when interfaceElement.type is product-listing' , async ( ) => {
99+ it ( 'should call buildProductListing with engine when interfaceElement.type is product-listing' , async ( ) => {
108100 const element = await renderPager ( {
109101 interfaceType : 'product-listing' ,
110102 } ) ;
@@ -113,7 +105,7 @@ describe('atomic-commerce-pager', () => {
113105 expect ( element . pager ) . toBeDefined ( ) ;
114106 } ) ;
115107
116- test ( 'should call buildSearch with engine when interfaceElement.type is search' , async ( ) => {
108+ it ( 'should call buildSearch with engine when interfaceElement.type is search' , async ( ) => {
117109 const element = await renderPager ( {
118110 interfaceType : 'search' ,
119111 } ) ;
@@ -122,7 +114,7 @@ describe('atomic-commerce-pager', () => {
122114 expect ( element . pager ) . toBeDefined ( ) ;
123115 } ) ;
124116
125- test ( 'should show the proper page range by default' , async ( ) => {
117+ it ( 'should show the proper page range by default' , async ( ) => {
126118 await renderPager ( ) ;
127119
128120 await expect . element ( locators . page1 ) . toBeInTheDocument ( ) ;
@@ -133,7 +125,7 @@ describe('atomic-commerce-pager', () => {
133125 await expect . element ( locators . page6 ) . not . toBeInTheDocument ( ) ;
134126 } ) ;
135127
136- test ( 'number-of-pages should affect the range of pages' , async ( ) => {
128+ it ( 'number-of-pages should affect the range of pages' , async ( ) => {
137129 await renderPager ( { numberOfPages : 3 } ) ;
138130
139131 await expect . element ( locators . page1 ) . toBeInTheDocument ( ) ;
@@ -142,7 +134,7 @@ describe('atomic-commerce-pager', () => {
142134 await expect . element ( locators . page4 ) . not . toBeInTheDocument ( ) ;
143135 } ) ;
144136
145- test ( 'should throw an error when numberOfPages is less than 0' , async ( ) => {
137+ it ( 'should throw an error when numberOfPages is less than 0' , async ( ) => {
146138 const consoleErrorSpy = vi
147139 . spyOn ( console , 'error' )
148140 . mockImplementation ( ( ) => { } ) ;
@@ -158,25 +150,25 @@ describe('atomic-commerce-pager', () => {
158150 ) ;
159151 } ) ;
160152
161- test ( 'should not render when there are no pages' , async ( ) => {
153+ it ( 'should not render when there are no pages' , async ( ) => {
162154 await renderPager ( { state : { totalPages : 0 } } ) ;
163155
164156 await expect . element ( locators . page1 ) . not . toBeInTheDocument ( ) ;
165157 } ) ;
166158
167- test ( 'should not render when there is only 1 page' , async ( ) => {
159+ it ( 'should not render when there is only 1 page' , async ( ) => {
168160 await renderPager ( { state : { totalPages : 1 } } ) ;
169161
170162 await expect . element ( locators . page1 ) . not . toBeInTheDocument ( ) ;
171163 } ) ;
172164
173- test ( 'should disable the previous button when on the first page' , async ( ) => {
165+ it ( 'should disable the previous button when on the first page' , async ( ) => {
174166 await renderPager ( ) ;
175167
176168 await expect . element ( locators . previous ) . toHaveAttribute ( 'disabled' ) ;
177169 } ) ;
178170
179- test ( 'should disable the next button when on the last page' , async ( ) => {
171+ it ( 'should disable the next button when on the last page' , async ( ) => {
180172 await renderPager ( { state : { page : 9 , totalPages : 10 } } ) ;
181173
182174 await expect . element ( locators . next ) . toHaveAttribute ( 'disabled' ) ;
@@ -201,17 +193,17 @@ describe('atomic-commerce-pager', () => {
201193 await locators . previous . click ( ) ;
202194 } ) ;
203195
204- test ( 'should call #focusOnFirstResultAfterNextSearch' , async ( ) => {
196+ it ( 'should call #focusOnFirstResultAfterNextSearch' , async ( ) => {
205197 expect ( focusSpy ) . toHaveBeenCalled ( ) ;
206198 } ) ;
207199
208- test ( "should dispatch 'atomic/scrollToTop'" , async ( ) => {
200+ it ( "should dispatch 'atomic/scrollToTop'" , async ( ) => {
209201 expect ( eventSpy ) . toHaveBeenCalledWith (
210202 new CustomEvent ( 'atomic/scrollToTop' )
211203 ) ;
212204 } ) ;
213205
214- test ( 'should call #pager.previousPage' , async ( ) => {
206+ it ( 'should call #pager.previousPage' , async ( ) => {
215207 expect ( previousSpy ) . toHaveBeenCalled ( ) ;
216208 } ) ;
217209
@@ -239,17 +231,17 @@ describe('atomic-commerce-pager', () => {
239231 await locators . next . click ( ) ;
240232 } ) ;
241233
242- test ( 'should call #focusOnFirstResultAfterNextSearch' , async ( ) => {
234+ it ( 'should call #focusOnFirstResultAfterNextSearch' , async ( ) => {
243235 expect ( focusSpy ) . toHaveBeenCalled ( ) ;
244236 } ) ;
245237
246- test ( "should dispatch 'atomic/scrollToTop'" , async ( ) => {
238+ it ( "should dispatch 'atomic/scrollToTop'" , async ( ) => {
247239 expect ( eventSpy ) . toHaveBeenCalledWith (
248240 new CustomEvent ( 'atomic/scrollToTop' )
249241 ) ;
250242 } ) ;
251243
252- test ( 'should call #pager.nextPage' , async ( ) => {
244+ it ( 'should call #pager.nextPage' , async ( ) => {
253245 expect ( nextSpy ) . toHaveBeenCalled ( ) ;
254246 } ) ;
255247
@@ -274,30 +266,30 @@ describe('atomic-commerce-pager', () => {
274266 await locators . page3 . click ( ) ;
275267 } ) ;
276268
277- test ( 'should call #focusOnFirstResultAfterNextSearch' , async ( ) => {
269+ it ( 'should call #focusOnFirstResultAfterNextSearch' , async ( ) => {
278270 expect ( focusSpy ) . toHaveBeenCalled ( ) ;
279271 } ) ;
280272
281- test ( "should dispatch 'atomic/scrollToTop'" , async ( ) => {
273+ it ( "should dispatch 'atomic/scrollToTop'" , async ( ) => {
282274 expect ( eventSpy ) . toHaveBeenCalledWith (
283275 new CustomEvent ( 'atomic/scrollToTop' )
284276 ) ;
285277 } ) ;
286278
287- test ( 'should call #pager.selectPage' , async ( ) => {
279+ it ( 'should call #pager.selectPage' , async ( ) => {
288280 expect ( selectPageSpy ) . toHaveBeenCalled ( ) ;
289281 } ) ;
290282 } ) ;
291283
292- test ( 'should render the proper value on the page buttons' , async ( ) => {
284+ it ( 'should render the proper value on the page buttons' , async ( ) => {
293285 await renderPager ( ) ;
294286
295287 await expect . element ( locators . page1 ) . toHaveAttribute ( 'value' , '1' ) ;
296288 await expect . element ( locators . page2 ) . toHaveAttribute ( 'value' , '2' ) ;
297289 await expect . element ( locators . page3 ) . toHaveAttribute ( 'value' , '3' ) ;
298290 } ) ;
299291
300- test ( 'should have the selected button as active' , async ( ) => {
292+ it ( 'should have the selected button as active' , async ( ) => {
301293 await renderPager ( ) ;
302294
303295 await expect
@@ -306,7 +298,7 @@ describe('atomic-commerce-pager', () => {
306298 await expect . element ( locators . page2 ) . toHaveAttribute ( 'part' , 'page-button' ) ;
307299 } ) ;
308300
309- test ( 'should be able to render a custom icon for the previous button' , async ( ) => {
301+ it ( 'should be able to render a custom icon for the previous button' , async ( ) => {
310302 const icon = '<svg>random-previous-icon</svg>' ;
311303 const element = await renderPager ( {
312304 previousButtonIcon : icon ,
@@ -318,7 +310,7 @@ describe('atomic-commerce-pager', () => {
318310 expect ( atomicIcon ) . toHaveAttribute ( 'icon' , icon ) ;
319311 } ) ;
320312
321- test ( 'should be able to render a custom icon for the next button' , async ( ) => {
313+ it ( 'should be able to render a custom icon for the next button' , async ( ) => {
322314 const icon = '<svg>random-next-icon</svg>' ;
323315 const element = await renderPager ( {
324316 nextButtonIcon : icon ,
@@ -330,7 +322,7 @@ describe('atomic-commerce-pager', () => {
330322 expect ( atomicIcon ) . toHaveAttribute ( 'icon' , icon ) ;
331323 } ) ;
332324
333- test ( 'should render every part' , async ( ) => {
325+ it ( 'should render every part' , async ( ) => {
334326 const element = await renderPager ( ) ;
335327
336328 const parts = locators . parts ( element ) ;
@@ -345,7 +337,7 @@ describe('atomic-commerce-pager', () => {
345337 await expect . element ( parts . nextButtonIcon ! ) . toBeInTheDocument ( ) ;
346338 } , 1e60 ) ;
347339
348- test ( 'should use keyed directive for page buttons' , async ( ) => {
340+ it ( 'should use keyed directive for page buttons' , async ( ) => {
349341 await renderPager ( ) ;
350342
351343 await expect . element ( locators . page1 ) . toHaveAttribute ( 'value' , '1' ) ;
@@ -375,7 +367,7 @@ describe('atomic-commerce-pager', () => {
375367 await expect . element ( button ) . toBe ( expectedFocusButton ) ;
376368 } ;
377369
378- test ( 'should focus on previous button when navigating backward from first page button' , async ( ) => {
370+ it ( 'should focus on previous button when navigating backward from first page button' , async ( ) => {
379371 const buttons = retrieveButtons ( ) ;
380372
381373 const [ firstPageButton , lastPageButton ] = [
@@ -391,7 +383,7 @@ describe('atomic-commerce-pager', () => {
391383 ) ;
392384 } ) ;
393385
394- test ( 'should focus on next button when navigating forward from last page button' , async ( ) => {
386+ it ( 'should focus on next button when navigating forward from last page button' , async ( ) => {
395387 const buttons = retrieveButtons ( ) ;
396388
397389 const [ firstPageButton , lastPageButton ] = [
@@ -407,7 +399,7 @@ describe('atomic-commerce-pager', () => {
407399 ) ;
408400 } ) ;
409401
410- test ( 'should focus on next page button when navigating between page buttons' , async ( ) => {
402+ it ( 'should focus on next page button when navigating between page buttons' , async ( ) => {
411403 const buttons = retrieveButtons ( ) ;
412404
413405 const [ currentButton , nextButton ] = buttons ;
0 commit comments