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

Commit

Permalink
fix(vue): vue created() does not check if mixin should run
Browse files Browse the repository at this point in the history
  • Loading branch information
michiel committed Aug 30, 2019
1 parent a57285f commit 1c46520
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/vue/__tests__/Mixin/Collection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,23 @@ describe('The Collection mixin', () => {

expect(mixin.$store.getters['hyral_product/collection']).not.toHaveBeenCalled();
});

test('that the mixin doesn\'t initialize if the component does not define the collectionName or resourceType', () => {
const mixin = Object.assign({
initCollection: jest.fn(),
loadCollection: jest.fn(),
}, collectionMixin);

mixin.serverPrefetch();
expect(mixin.initCollection).not.toHaveBeenCalled();
expect(mixin.loadCollection).not.toHaveBeenCalled();

mixin.mounted();
expect(mixin.initCollection).not.toHaveBeenCalled();
expect(mixin.loadCollection).not.toHaveBeenCalled();

mixin.created();
expect(mixin.initCollection).not.toHaveBeenCalled();
expect(mixin.loadCollection).not.toHaveBeenCalled();
});
});
4 changes: 4 additions & 0 deletions packages/vue/src/Mixin/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default {
},
},
created() {
if (!this.collectionName || !this.resourceType) {
return;
}

this.initCollection();
},
/**
Expand Down

0 comments on commit 1c46520

Please sign in to comment.