"@types/redux-devtools": "3.0.44",
"@types/sinon": "7.5",
"@types/uuid": "3.4.4",
- "axios-mock-adapter": "1.15.0",
+ "axios-mock-adapter": "1.17.0",
"enzyme": "3.6.0",
"enzyme-adapter-react-16": "1.5.0",
"jest-localstorage-mock": "2.2.0",
});
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 () => {
itemsAvailable: 20
});
});
+
+ it("#list using POST when query string is too big", async () => {
+ axiosMock
+ .onPost("/resource")
+ .reply(200);
+ const tooBig = 'x'.repeat(1500);
+ const commonResourceService = new CommonResourceService(axiosInstance, "resource", actions);
+ const resource = 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].params._method).toBe('GET');
+ });
});
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==
-axios-mock-adapter@1.15.0:
- version "1.15.0"
- resolved "https://registry.yarnpkg.com/axios-mock-adapter/-/axios-mock-adapter-1.15.0.tgz#fbc06825d8302c95c3334d21023bba996255d45d"
- integrity sha1-+8BoJdgwLJXDM00hAju6mWJV1F0=
+axios-mock-adapter@1.17.0:
+ version "1.17.0"
+ resolved "https://registry.yarnpkg.com/axios-mock-adapter/-/axios-mock-adapter-1.17.0.tgz#0dbee43c606d4aaba5a43d88d96d6661a7cc3c04"
+ integrity sha512-q3efmwJUOO4g+wsLNSk9Ps1UlJoF3fQ3FSEe4uEEhkRtu7SoiAVPj8R3Hc/WP55MBTVFzaDP9QkdJhdVhP8A1Q==
dependencies:
deep-equal "^1.0.1"