Olivier Massot 2 anni fa
parent
commit
cddbd3a72b

+ 10 - 17
tests/units/services/data/apiRequestService.test.ts

@@ -31,7 +31,7 @@ describe('get', () => {
         expect(result).toEqual('a_response')
         // @ts-ignore
         expect(apiRequestService.request).toHaveBeenCalledWith(
-            HTTP_METHOD.GET, 'https://myapi.com/api/item', null, null, { a: 1 }
+            HTTP_METHOD.GET, 'https://myapi.com/api/item', null, { a: 1 }
         )
     })
 })
@@ -44,8 +44,7 @@ describe('post', () => {
         const result = await apiRequestService.post(
             'https://myapi.com/api/item',
             'request_body',
-            { a: 1 },
-            { b: 2 },
+            { a: 1 }
         )
 
         expect(result).toEqual('a_response')
@@ -54,8 +53,7 @@ describe('post', () => {
             HTTP_METHOD.POST,
             'https://myapi.com/api/item',
             'request_body',
-            { a: 1 },
-            { b: 2 }
+            { a: 1 }
         )
     })
 })
@@ -68,8 +66,7 @@ describe('put', () => {
         const result = await apiRequestService.put(
             'https://myapi.com/api/item',
             'request_body',
-            { a: 1 },
-            { b: 2 },
+            { a: 1 }
         )
 
         expect(result).toEqual('a_response')
@@ -78,8 +75,7 @@ describe('put', () => {
             HTTP_METHOD.PUT,
             'https://myapi.com/api/item',
             'request_body',
-            { a: 1 },
-            { b: 2 }
+            { a: 1 }
         )
     })
 })
@@ -91,7 +87,7 @@ describe('delete', () => {
 
         const result = await apiRequestService.delete(
             'https://myapi.com/api/item',
-            { a: 1 },
+            { a: 1 }
         )
 
         expect(result).toEqual('a_response')
@@ -100,8 +96,7 @@ describe('delete', () => {
             HTTP_METHOD.DELETE,
             'https://myapi.com/api/item',
             null,
-            null,
-            { a: 1 },
+            { a: 1 }
         )
     })
 })
@@ -147,14 +142,13 @@ describe('request', () => {
         expect(fetcher).toHaveBeenCalledWith('https://myapi.com/api/item', {method: 'GET'})
     })
 
-    test('with query and params', async () => {
+    test('with query', async () => {
         // @ts-ignore
         const result = await apiRequestService.request(
             HTTP_METHOD.PUT,
             'https://myapi.com/api/item',
             'a_body',
-            { a: 1 },
-            { b: 2 }
+            { a: 1 }
         )
 
         expect(result).toEqual('fetch_response')
@@ -164,8 +158,7 @@ describe('request', () => {
             {
                 method: 'PUT',
                 body: 'a_body',
-                params: { a: 1 },
-                query: { b: 2 },
+                query: { a: 1 },
             }
         )
     })

+ 2 - 2
tests/units/services/data/entityManager.test.ts

@@ -294,7 +294,7 @@ describe('fetchCollection', () => {
 
         const result = await entityManager.fetchCollection(DummyApiResource, null)
 
-        expect(apiRequestService.get).toHaveBeenCalledWith('api/dummyResource', [])
+        expect(apiRequestService.get).toHaveBeenCalledWith('api/dummyResource', null)
         expect(entityManager.newInstance).toHaveBeenCalledTimes(3)
         expect(entityManager.newInstance).toHaveBeenCalledWith(DummyApiResource, {id: 1})
         expect(entityManager.newInstance).toHaveBeenCalledWith(DummyApiResource, {id: 2})
@@ -340,7 +340,7 @@ describe('fetchCollection', () => {
 
         await entityManager.fetchCollection(DummyApiResource, parent)
 
-        expect(apiRequestService.get).toHaveBeenCalledWith('api/dummyModel/100/dummyResource', [])
+        expect(apiRequestService.get).toHaveBeenCalledWith('api/dummyModel/100/dummyResource', null)
     })
 
     test('with a query', async () => {

+ 2 - 2
tests/units/services/layout/menuBuilder/configurationMenuBuilder.test.ts

@@ -79,7 +79,7 @@ describe('build', () => {
         ability.can = vi.fn((action: string, subject: string) => action === 'display' && subject === 'place_page')
 
         expect(menuBuilder.build()).toEqual(
-            {label: 'place', icon: undefined, to: 'https://mydomain.com/#/places/list/', type: MENU_LINK_TYPE.V1, active: false}
+            {label: 'places', icon: undefined, to: 'https://mydomain.com/#/places/list/', type: MENU_LINK_TYPE.V1, active: false}
         )
     })
 
@@ -95,7 +95,7 @@ describe('build', () => {
         ability.can = vi.fn((action: string, subject: string) => action === 'display' && subject === 'tag_page')
 
         expect(menuBuilder.build()).toEqual(
-            {label: 'tag', icon: undefined, to: 'https://mydomain.com/#/taggs/list/', type: MENU_LINK_TYPE.V1, active: false}
+            {label: 'tags', icon: undefined, to: 'https://mydomain.com/#/taggs/list/', type: MENU_LINK_TYPE.V1, active: false}
         )
     })