feat: Rewrite accountMixin to a composable (#9914)
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
import { mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapGetters({
|
||||
accountId: 'getCurrentAccountId',
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
addAccountScoping(url) {
|
||||
return `/app/accounts/${this.accountId}/${url}`;
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||
import accountMixin from '../account';
|
||||
import Vuex from 'vuex';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
|
||||
describe('accountMixin', () => {
|
||||
let getters;
|
||||
let store;
|
||||
|
||||
beforeEach(() => {
|
||||
getters = {
|
||||
getCurrentAccountId: () => 1,
|
||||
};
|
||||
|
||||
store = new Vuex.Store({ getters });
|
||||
});
|
||||
|
||||
it('set accountId properly', () => {
|
||||
const Component = {
|
||||
render() {},
|
||||
title: 'TestComponent',
|
||||
mixins: [accountMixin],
|
||||
};
|
||||
const wrapper = shallowMount(Component, { store, localVue });
|
||||
expect(wrapper.vm.accountId).toBe(1);
|
||||
});
|
||||
|
||||
it('returns current url', () => {
|
||||
const Component = {
|
||||
render() {},
|
||||
title: 'TestComponent',
|
||||
mixins: [accountMixin],
|
||||
};
|
||||
|
||||
const wrapper = shallowMount(Component, { store, localVue });
|
||||
expect(wrapper.vm.addAccountScoping('settings/inboxes/new')).toBe(
|
||||
'/app/accounts/1/settings/inboxes/new'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user