Skip to content

Commit

Permalink
test(items): test body of addItemData request in browser tests
Browse files Browse the repository at this point in the history
AFFECTS PACKAGES:
@esri/arcgis-rest-items
  • Loading branch information
Noah Mulfinger authored and noahmulfinger committed Aug 10, 2018
1 parent 401c6dd commit 2710f4c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/arcgis-rest-items/test/items.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,12 @@ describe("search", () => {
success: true
});

const file = attachmentFile();

addItemData({
id: "3ef",
// File() is only available in the browser
data: attachmentFile(),
data: file,
...MOCK_USER_REQOPTS
})
.then(() => {
Expand All @@ -687,10 +689,12 @@ describe("search", () => {
expect(options.method).toBe("POST");
expect(options.body instanceof FormData).toBeTruthy();
const params = options.body as FormData;
// need to figure out how to introspect FormData from Node.js
// expect(params.get("token")).toEqual("fake-token");
// expect(params.get("f")).toEqual("json");
// expect(params.get("filename")).toEqual("foo.txt");
if (params.get) {
expect(params.get("token")).toEqual("fake-token");
expect(params.get("f")).toEqual("json");
expect(params.get("file")).toEqual(file);
}

done();
})
.catch(e => {
Expand Down

0 comments on commit 2710f4c

Please sign in to comment.