Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
fix(vue): collection state only stores non-complex items #92
Browse files Browse the repository at this point in the history
  • Loading branch information
michiel committed Jul 24, 2019
1 parent b61f110 commit 4bfbeda
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/core/__tests__/Resource/Collection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ describe('Collection tests', () => {
expect(newCollection.isLoaded).toEqual(state.metadata.loaded);
});

test('that the collection stores only the resource state and not the instances', () => {
const newCollection = Collection.fromState('test', state, productRepository);

expect(newCollection.items).toHaveLength(1);
expect(newCollection.state).toHaveProperty('data');
expect(newCollection.state.data).toHaveProperty('items');
expect(newCollection.state.data.items).toHaveLength(1);
expect(newCollection.state.data.items[0]).toHaveProperty('id');
expect(newCollection.state.data.items[0]).toHaveProperty('type');
expect(newCollection.state.data.items[0]).toHaveProperty('state');
});

test('that a new collection can be made based on an invalid state', () => {
const newCollection = Collection.fromState('test', {}, {});

Expand Down

0 comments on commit 4bfbeda

Please sign in to comment.