@@ -481,6 +481,46 @@ describe('User actions', () => {
481481 expect ( EventBus . $emit ) . toBeCalledWith ( 'user-after-loaded-orders' , result ) ;
482482 expect ( result ) . toBe ( responseOb . result )
483483 } )
484+
485+ it ( 'returns unique orders' , async ( ) => {
486+ const oldOrders = [
487+ { name : 'a' , increment_id : 0 } ,
488+ { name : 'b' , increment_id : 1 }
489+ ]
490+ const orders = {
491+ items : [
492+ { name : 'a' , increment_id : 0 } ,
493+ { name : 'c' , increment_id : 2 }
494+ ]
495+ }
496+ const responseOb = {
497+ result : orders ,
498+ code : 200
499+ } ;
500+ const contextMock = {
501+ commit : jest . fn ( ) ,
502+ getters : {
503+ getOrdersHistory : oldOrders
504+ }
505+ } ;
506+ const pageSize = data . pageSize ;
507+ const currentPage = data . currentPage ;
508+
509+ ( UserService . getOrdersHistory as jest . Mock ) . mockImplementation ( async ( ) => responseOb ) ;
510+ const result = await ( userActions as any ) . appendOrdersHistory ( contextMock , {
511+ pageSize,
512+ currentPage
513+ } )
514+ const expectedResult = {
515+ items : [
516+ { name : 'a' , increment_id : 0 } ,
517+ { name : 'b' , increment_id : 1 } ,
518+ { name : 'c' , increment_id : 2 }
519+ ]
520+ }
521+
522+ expect ( result ) . toEqual ( expectedResult ) ;
523+ } )
484524 } )
485525
486526 describe ( 'refreshOrderHistory action' , ( ) => {
0 commit comments