@@ -32,6 +32,19 @@ it('should render pagination items if "total" props is provided', () => {
32
32
expect ( paginationItems ) . toHaveLength ( 5 )
33
33
} )
34
34
35
+ it ( 'should render no pagination item if "total" props less than zero' , ( ) => {
36
+ const screen = render ( {
37
+ components : { Pagination } ,
38
+ template : '<Pagination :total="-100" />' ,
39
+ } )
40
+
41
+ const pagination = screen . getByTestId ( 'pagination' )
42
+ const paginationItems = screen . queryAllByTestId ( 'pagination-item' )
43
+
44
+ expect ( pagination ) . toBeInTheDocument ( )
45
+ expect ( paginationItems ) . toHaveLength ( 0 )
46
+ } )
47
+
35
48
it ( 'should render only one page item if "total" props less than provided or default "per-page" props' , ( ) => {
36
49
const screen = render ( {
37
50
components : { Pagination } ,
@@ -290,6 +303,26 @@ it('should bind total page to "v-model", if total page count less than current p
290
303
expect ( model . value ) . toBe ( 5 )
291
304
} )
292
305
306
+ it ( 'should not change "v-model" to zero, if total pagination changed to zero' , async ( ) => {
307
+ const model = ref ( 1 )
308
+ const total = ref ( 100 )
309
+
310
+ render ( {
311
+ components : { Pagination } ,
312
+ template : '<Pagination v-model="model" :total="total" :per-page="10" />' ,
313
+ setup ( ) {
314
+ return { model, total }
315
+ } ,
316
+ } )
317
+
318
+ expect ( model . value ) . toBe ( 1 )
319
+
320
+ total . value = 0
321
+ await nextTick ( )
322
+
323
+ expect ( model . value ) . toBe ( 1 )
324
+ } )
325
+
293
326
it ( 'should not change "v-model", if ellipsis is clicked' , async ( ) => {
294
327
const model = ref ( 1 )
295
328
const screen = render ( {
0 commit comments