Skip to content

Commit bdb9a36

Browse files
committed
Return the patched original entity
1 parent 97d9312 commit bdb9a36

8 files changed

+109
-103
lines changed

dist/vuex-rest-plugin.common.js

Lines changed: 50 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuex-rest-plugin.common.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuex-rest-plugin.umd.js

Lines changed: 50 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuex-rest-plugin.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuex-rest-plugin.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vuex-rest-plugin.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ApiStore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,15 @@ export default class ApiStore<S> implements StoreOptions<S> {
207207
}
208208
}
209209
});
210+
211+
return store.items[entity.id];
210212
} else {
211213
store.items = { ...store.items, [entity.id]: entity };
212214
this.storeOriginItem(store.originItems, entity, model.beforeQueue);
215+
216+
return entity;
213217
}
214218
}
215-
return entity;
216219
}
217220

218221
private async patchReference(

tests/unit/apistoreCustomModel.spec.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ describe("ApiStore custom model", function() {
361361
id: string;
362362
user?: CustomUser;
363363
someId: string;
364-
localProp = false;
365364
constructor(o: any) {
366365
this.id = o.id;
367366
this.user = new CustomUser(o.user);
@@ -403,7 +402,6 @@ describe("ApiStore custom model", function() {
403402
]
404403
});
405404
const resource = data[0];
406-
const user = data[0].user;
407405
mock.onGet(`/resource/${resource.id}`).reply(200, resource);
408406
store.dispatch("api/get", {
409407
id: resource.id,
@@ -416,22 +414,13 @@ describe("ApiStore custom model", function() {
416414
expect(store.getters["api/users"].items[resource.user.id]).toBeInstanceOf(
417415
CustomUser
418416
);
419-
420-
store.getters["api/users"].items[user.id].localProp = true;
421-
422-
mock.onGet(`/user/${user.id}`).reply(200, user);
423-
store.dispatch("api/get", {
424-
id: user.id,
425-
type: "user"
426-
});
427-
await flushPromises();
428-
expect(store.getters["api/users"].items[user.id].localProp).toBe(true);
429417
});
430418

431419
it("test class with local property", async () => {
432420
class CustomUser {
433421
id: string;
434422
someId: string;
423+
localProp = false;
435424
constructor(o: any) {
436425
this.id = o.id;
437426
this.someId = o.someId;

0 commit comments

Comments
 (0)