Skip to content

Commit

Permalink
fix(:bug:): tags arent required to create a group
Browse files Browse the repository at this point in the history
AFFECTS PACKAGES:
@esri/arcgis-rest-groups
@esri/arcgis-rest-items
  • Loading branch information
jgravois committed Nov 2, 2018
1 parent 6e6f7a6 commit 72ffd35
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/arcgis-rest-groups/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function serializeGroup(group: IGroupAdd | IItemUpdate | IGroup): any {
// create a clone so we're not messing with the original
const clone = JSON.parse(JSON.stringify(group));
// join and tags...
clone.tags = clone.tags.join(", ");
const { tags = [] } = group;
clone.tags = tags.join(", ");
return clone;
}
28 changes: 28 additions & 0 deletions packages/arcgis-rest-groups/test/crud.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,34 @@ describe("groups", () => {
expect(options.body).toContain(encodeParam("owner", "fakeUser"));
// ensure the array props are serialized into strings
expect(options.body).toContain(encodeParam("tags", "foo, bar"));
expect(options.body).toContain(encodeParam("access", "public"));
done();
})
.catch(e => {
fail(e);
});
});

it("should create a group without an owner or tags", done => {
fetchMock.once("*", GroupEditResponse);
const fakeGroup = {
title: "bone stock fake group",
access: "org"
} as IGroupAdd;
createGroup({ group: fakeGroup, ...MOCK_REQOPTS })
.then(response => {
expect(fetchMock.called()).toEqual(true);
const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
expect(url).toEqual(
"https://myorg.maps.arcgis.com/sharing/rest/community/createGroup"
);
expect(options.method).toBe("POST");
expect(options.body).toContain(encodeParam("f", "json"));
expect(options.body).toContain(encodeParam("token", "fake-token"));
expect(options.body).toContain(
encodeParam("title", "bone stock fake group")
);
expect(options.body).toContain(encodeParam("access", "org"));
done();
})
.catch(e => {
Expand Down
2 changes: 1 addition & 1 deletion packages/arcgis-rest-items/test/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe("search", () => {
const fakeItem = {
title: "my fake item",
description: "yep its fake",
snipped: "so very fake",
snippet: "so very fake",
type: "Web Mapping Application",
properties: {
key: "somevalue"
Expand Down

0 comments on commit 72ffd35

Please sign in to comment.