resourcerer 2.1.1 → 2.1.2

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.
@@ -118,7 +118,7 @@ export default class Model extends Events {
118
118
  this.isNew() ? "POST"
119
119
  : options.patch ? "PATCH"
120
120
  : "PUT";
121
- if (options.method === "PATCH" && !options.attrs) {
121
+ if (options.method === "PATCH") {
122
122
  options.attrs = attrs;
123
123
  }
124
124
  return this.sync(this, options)
package/build/lib/sync.js CHANGED
@@ -5,9 +5,10 @@ let prefilter = (x) => x;
5
5
  export default function (model, options = {}) {
6
6
  return ajax({
7
7
  contentType: MIME_TYPE_JSON,
8
- params: options.params || ["POST", "PATCH", "PUT"].includes(options.method || "") ?
9
- options.attrs || model.toJSON()
10
- : {},
8
+ params: options.params ||
9
+ (["POST", "PATCH", "PUT"].includes(options.method || "") ?
10
+ options.attrs || model.toJSON()
11
+ : {}),
11
12
  url: options.url || result(model, "url", model.urlOptions) || urlError(),
12
13
  error: (response) => response,
13
14
  ...options,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resourcerer",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "github.com/noahgrant/resourcerer"
@@ -287,6 +287,15 @@ describe("Model", () => {
287
287
  method: "PATCH",
288
288
  attrs: { one: "one" },
289
289
  });
290
+ sync.default.mockClear();
291
+ await model.save({ one: "one" }, { patch: true, wait: true });
292
+ expect(sync.default).toHaveBeenCalledWith(model, {
293
+ parse: true,
294
+ patch: true,
295
+ wait: true,
296
+ method: "PATCH",
297
+ attrs: { one: "one" },
298
+ });
290
299
  });
291
300
 
292
301
  it("parses results unless `parse` is set to false", async () => {