Skip to content

Commit

Permalink
Merge pull request #211 from probil/bugfix/#189-mixins-support
Browse files Browse the repository at this point in the history
Bugfix/#189 mixins support
  • Loading branch information
probil authored Dec 2, 2018
2 parents dcfc247 + 7a770e7 commit ff680ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default {
// eslint-disable-next-line no-param-reassign
Vue.prototype.$socket = socket;
Vue.mixin(createMixin(GlobalEmitter));
const strategies = Vue.config.optionMergeStrategies;
strategies.sockets = strategies.methods;
},
defaults,
};
19 changes: 19 additions & 0 deletions src/__tests__/Main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ describe('.install()', () => {
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(expect.any(Object));
});

it('correctly merges `sockets` property of the mixin and the component', () => {
Vue.use(Main, io('ws://localhost'));
const mixinListener = jest.fn();
const componentListener = jest.fn();
const someMixin = {
sockets: { mixinListener },
};
const wrapper = mount({
mixins: [someMixin],
render: () => null,
sockets: { componentListener },
}, { localVue: Vue });

expect(wrapper.vm.$options.sockets).toMatchObject({
mixinListener,
componentListener,
});
});
});

describe('.defaults', () => {
Expand Down

0 comments on commit ff680ec

Please sign in to comment.