Skip to content

Commit

Permalink
fix(arcgis-rest-request): adds test to issue with append custom params
Browse files Browse the repository at this point in the history
  • Loading branch information
drspacemanphd committed Apr 7, 2022
1 parent 4a63dd7 commit 2b9060f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/arcgis-rest-portal/test/items/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ describe("search", () => {
});
});

it("should properly handle options for which 0 is a valid value", (done) => {
fetchMock.once("*", SearchResponse);

searchItems({
q: "DC AND typekeywords:hubSiteApplication",
num: 0,
start: 22,
sortField: "title",
sortOrder: "desc",
searchUserAccess: "groupMember",
searchUserName: "casey",
foo: "bar" // this one should not end up on the url
})
.then(() => {
expect(fetchMock.called()).toEqual(true);
const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
expect(url).toEqual(
"https://www.arcgis.com/sharing/rest/search?f=json&q=DC%20AND%20typekeywords%3AhubSiteApplication&num=0&start=22&sortField=title&sortOrder=desc&searchUserAccess=groupMember&searchUserName=casey"
);
expect(options.method).toBe("GET");
done();
})
.catch((e) => {
fail(e);
});
});

it("should pass through other requestOptions at the same time", (done) => {
fetchMock.once("*", SearchResponse);

Expand Down

0 comments on commit 2b9060f

Please sign in to comment.