Skip to content

Commit

Permalink
Issue #40 Add unit tests for the state and mutations for loading in t…
Browse files Browse the repository at this point in the history
…he store
  • Loading branch information
Bruno P. Kinoshita committed Mar 5, 2019
1 parent fa4178f commit a81e850
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/unit/store/store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,23 @@ describe('store', () => {
store.dispatch('removeAlert', 'my-alert');
expect(store.state.alerts.length).to.equal(1);
});
})
});
describe('loading', () => {
it('should start with loading false', () => {
expect(store.state.isLoading).to.equal(false);
expect(store.state.refCount).to.equal(0);
});
it('should update refCount correctly', () => {
expect(store.state.refCount).to.equal(0);
store.dispatch('setLoading', true);
store.dispatch('setLoading', true);
expect(store.state.refCount).to.equal(2);
store.dispatch('setLoading', false);
expect(store.state.refCount).to.equal(1);
store.dispatch('setLoading', false);
expect(store.state.refCount).to.equal(0);
store.dispatch('setLoading', false);
expect(store.state.refCount).to.equal(0);
});
});
});

0 comments on commit a81e850

Please sign in to comment.