resourcerer 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/sync.js +3 -1
- package/package.json +1 -1
- package/test/sync.test.js +4 -3
package/build/lib/sync.js
CHANGED
|
@@ -38,7 +38,9 @@ export function ajax(options) {
|
|
|
38
38
|
...options,
|
|
39
39
|
headers: {
|
|
40
40
|
Accept: MIME_TYPE_JSON,
|
|
41
|
-
...(hasBodyContent
|
|
41
|
+
...(hasBodyContent && !(options.params instanceof FormData) ?
|
|
42
|
+
{ "Content-Type": options.contentType }
|
|
43
|
+
: {}),
|
|
42
44
|
...options.headers,
|
|
43
45
|
},
|
|
44
46
|
...(hasBodyContent ?
|
package/package.json
CHANGED
package/test/sync.test.js
CHANGED
|
@@ -22,7 +22,7 @@ describe("sync", () => {
|
|
|
22
22
|
beforeEach(() => {
|
|
23
23
|
library = new Library();
|
|
24
24
|
vi.spyOn(window, "fetch").mockResolvedValue(
|
|
25
|
-
new Response(JSON.stringify({ test: "response!" }), { status: 200 })
|
|
25
|
+
new Response(JSON.stringify({ test: "response!" }), { status: 200 }),
|
|
26
26
|
);
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -93,6 +93,7 @@ describe("sync", () => {
|
|
|
93
93
|
await library.at(0).save(null, { params: formData, contentType: "multipart/form-data" });
|
|
94
94
|
expect(window.fetch.mock.calls[0][0]).toEqual("/library");
|
|
95
95
|
expect(window.fetch.mock.calls[0][1].body).toEqual(formData);
|
|
96
|
+
expect(window.fetch.mock.calls[0][1].headers["Content-Type"]).not.toBeDefined();
|
|
96
97
|
});
|
|
97
98
|
|
|
98
99
|
it("passes urlOptions to the model to formulate the url path", async () => {
|
|
@@ -121,7 +122,7 @@ describe("sync", () => {
|
|
|
121
122
|
|
|
122
123
|
librarySectionBook = new LibrarySectionBook(
|
|
123
124
|
{},
|
|
124
|
-
{ section: "nature", bookId: "all-about-frogs" }
|
|
125
|
+
{ section: "nature", bookId: "all-about-frogs" },
|
|
125
126
|
);
|
|
126
127
|
await librarySectionBook.fetch({ params: { a: "a", one: 1 } });
|
|
127
128
|
expect(window.fetch.mock.calls[2][0]).toEqual("/library/nature/all-about-frogs?a=a&one=1");
|
|
@@ -182,7 +183,7 @@ describe("sync", () => {
|
|
|
182
183
|
|
|
183
184
|
it("rejects non-2xx", async () => {
|
|
184
185
|
window.fetch.mockResolvedValue(
|
|
185
|
-
new Response(JSON.stringify({ test: "womp" }), { status: 500, type: "application/json" })
|
|
186
|
+
new Response(JSON.stringify({ test: "womp" }), { status: 500, type: "application/json" }),
|
|
186
187
|
);
|
|
187
188
|
|
|
188
189
|
try {
|