[ARVADOS-WORKBENCH2] updated: 1.4.1-211-g22a3f545

Git user git at public.arvados.org
Sat Jan 18 11:47:28 UTC 2020


Summary of changes:
 .../common-service/common-resource-service.test.ts       | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

       via  22a3f54534652000e7f0b537487e68572b403dcb (commit)
      from  6183e0220cbde9d020a9ebac412732a5ed41583a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 22a3f54534652000e7f0b537487e68572b403dcb
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Sat Jan 18 08:46:51 2020 -0300

    15672: Cleans & simplifies test code.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/services/common-service/common-resource-service.test.ts b/src/services/common-service/common-resource-service.test.ts
index a53ec400..943325b7 100644
--- a/src/services/common-service/common-resource-service.test.ts
+++ b/src/services/common-service/common-resource-service.test.ts
@@ -23,11 +23,12 @@ export const mockResourceService = <R extends Resource, C extends CommonResource
 };
 
 describe("CommonResourceService", () => {
-    const axiosInstance = axios.create();
-    const axiosMock = new MockAdapter(axiosInstance);
+    let axiosInstance: AxiosInstance;
+    let axiosMock: MockAdapter;
 
     beforeEach(() => {
-        axiosMock.reset();
+        axiosInstance = axios.create();
+        axiosMock = new MockAdapter(axiosInstance);
     });
 
     it("#create", async () => {
@@ -41,13 +42,10 @@ describe("CommonResourceService", () => {
     });
 
     it("#create maps request params to snake case", async () => {
-        const realPost = axiosInstance.post;
         axiosInstance.post = jest.fn(() => Promise.resolve({data: {}}));
         const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions);
         await commonResourceService.create({ ownerUuid: "ownerUuidValue" });
         expect(axiosInstance.post).toHaveBeenCalledWith("/resource", {owner_uuid: "ownerUuidValue"});
-        // Restore post function so that tests below don't break.
-        axiosInstance.post = realPost;
     });
 
     it("#delete", async () => {
@@ -116,14 +114,14 @@ describe("CommonResourceService", () => {
 
     it("#list using POST when query string is too big", async () => {
         axiosMock
-            .onPost("/resource")
+            .onAny("/resource")
             .reply(200);
         const tooBig = 'x'.repeat(1500);
         const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions);
-        const resource = await commonResourceService.list({ filters: tooBig });
+        await commonResourceService.list({ filters: tooBig });
         expect(axiosMock.history.get.length).toBe(0);
         expect(axiosMock.history.post.length).toBe(1);
-        expect(axiosMock.history.post[0].data.get('filters')).toBe('['+tooBig+']');
+        expect(axiosMock.history.post[0].data.get('filters')).toBe(`[${tooBig}]`);
         expect(axiosMock.history.post[0].params._method).toBe('GET');
     });
 });

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list