@@ -56,11 +56,11 @@ describe('product.mutations', () => {
5656
5757 describe ( 'useProductCreate' , ( ) => {
5858 it ( 'should create product and invalidate queries on success' , async ( ) => {
59- const mockProduct = { id : '1' , name : 'New Product' , description : 'Desc' , price : 100 , createdAt : new Date ( ) , updatedAt : new Date ( ) } ;
59+ const mockProduct = { id : '1' , name : 'New Product' , description : 'Desc' , price : 100 , type : 'comida' as const , createdAt : new Date ( ) , updatedAt : new Date ( ) } ;
6060 mockProductService . create . mockResolvedValue ( mockProduct ) ;
6161
6262 const { mutate } = useProductCreate ( ) ;
63- await mutate ( { name : 'New Product' , description : 'Desc' , price : 100 } ) ;
63+ await mutate ( { name : 'New Product' , description : 'Desc' , price : 100 , type : { label : 'Comida' , value : 'comida' } } ) ;
6464
6565 expect ( mockProductService . create ) . toHaveBeenCalled ( ) ;
6666 expect ( mockInvalidateQueries ) . toHaveBeenCalledWith ( {
@@ -69,11 +69,11 @@ describe('product.mutations', () => {
6969 } ) ;
7070
7171 it ( 'should show success toast on create' , async ( ) => {
72- const mockProduct = { id : '1' , name : 'New Product' , description : 'Desc' , price : 100 , createdAt : new Date ( ) , updatedAt : new Date ( ) } ;
72+ const mockProduct = { id : '1' , name : 'New Product' , description : 'Desc' , price : 100 , type : 'comida' as const , createdAt : new Date ( ) , updatedAt : new Date ( ) } ;
7373 mockProductService . create . mockResolvedValue ( mockProduct ) ;
7474
7575 const { mutate } = useProductCreate ( ) ;
76- await mutate ( { name : 'New Product' , description : 'Desc' , price : 100 } ) ;
76+ await mutate ( { name : 'New Product' , description : 'Desc' , price : 100 , type : { label : 'Comida' , value : 'comida' } } ) ;
7777
7878 // Toast is called via useAppStorage mock
7979 } ) ;
@@ -85,17 +85,17 @@ describe('product.mutations', () => {
8585 const { mutate } = useProductCreate ( ) ;
8686
8787 // The mutation will throw because the service returns an Error
88- await expect ( mutate ( { name : 'Test' , description : 'Desc' , price : 100 } ) ) . rejects . toThrow ( ) ;
88+ await expect ( mutate ( { name : 'Test' , description : 'Desc' , price : 100 , type : { label : 'Comida' , value : 'comida' } } ) ) . rejects . toThrow ( ) ;
8989 } ) ;
9090 } ) ;
9191
9292 describe ( 'useProductUpdate' , ( ) => {
9393 it ( 'should update product and invalidate queries on success' , async ( ) => {
94- const mockProduct = { id : '1' , name : 'Updated Product' , description : 'Desc' , price : 200 , createdAt : new Date ( ) , updatedAt : new Date ( ) } ;
94+ const mockProduct = { id : '1' , name : 'Updated Product' , description : 'Desc' , price : 200 , type : 'comida' as const , createdAt : new Date ( ) , updatedAt : new Date ( ) } ;
9595 mockProductService . update . mockResolvedValue ( mockProduct ) ;
9696
9797 const { mutate } = useProductUpdate ( ) ;
98- await mutate ( { id : '1' , form : { name : 'Updated Product' , description : 'Desc' , price : 200 } } ) ;
98+ await mutate ( { id : '1' , form : { name : 'Updated Product' , description : 'Desc' , price : 200 , type : { label : 'Comida' , value : 'comida' } } } ) ;
9999
100100 expect ( mockProductService . update ) . toHaveBeenCalledWith ( '1' , expect . any ( Object ) ) ;
101101 expect ( mockInvalidateQueries ) . toHaveBeenCalledWith ( {
@@ -113,7 +113,7 @@ describe('product.mutations', () => {
113113 const { mutate } = useProductUpdate ( ) ;
114114
115115 await expect (
116- mutate ( { id : '1' , form : { name : 'Test' , description : 'Desc' , price : 100 } } ) ,
116+ mutate ( { id : '1' , form : { name : 'Test' , description : 'Desc' , price : 100 , type : { label : 'Comida' , value : 'comida' } } } ) ,
117117 ) . rejects . toThrow ( ) ;
118118 } ) ;
119119 } ) ;
0 commit comments