15672: Adds test for params being just under the limit of needing POST.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 21 Jan 2020 15:06:00 +0000 (12:06 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 21 Jan 2020 15:06:00 +0000 (12:06 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/services/common-service/common-resource-service.test.ts

index 943325b75f13dba6d2d81031add51bbdf5f262c0..2a18ce2369b7f7bd849646f7458b1d716f69bd93 100644 (file)
@@ -124,4 +124,16 @@ describe("CommonResourceService", () => {
         expect(axiosMock.history.post[0].data.get('filters')).toBe(`[${tooBig}]`);
         expect(axiosMock.history.post[0].params._method).toBe('GET');
     });
+
+    it("#list using GET when query string is not too big", async () => {
+        axiosMock
+            .onAny("/resource")
+            .reply(200);
+        const notTooBig = 'x'.repeat(1480);
+        const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions);
+        await commonResourceService.list({ filters: notTooBig });
+        expect(axiosMock.history.post.length).toBe(0);
+        expect(axiosMock.history.get.length).toBe(1);
+        expect(axiosMock.history.get[0].params.filters).toBe(`[${notTooBig}]`);
+    });
 });