Skip to content

Commit

Permalink
chore(test): check cache hits for computed property
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban committed Jun 14, 2021
1 parent fd71456 commit 7e10e99
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/spec/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ describe("store:", () => {
expect(store.error(model)).toBeInstanceOf(Error);
});

it("calls computed property function only once", () => {
const spy = jasmine.createSpy();
Model = {
computed: model => {
spy(model);
return "value";
},
};

const model = store.get(Model);
expect(spy).toHaveBeenCalledTimes(0);
expect(model.computed).toBe("value");
expect(spy).toHaveBeenCalledTimes(1);
expect(model.computed).toBe("value");
expect(spy).toHaveBeenCalledTimes(1);
});

describe("for singleton", () => {
beforeEach(() => {
Model = {
Expand Down

0 comments on commit 7e10e99

Please sign in to comment.