feat: Rewrite accountMixin to a composable (#9914)

This commit is contained in:
Sivin Varghese
2024-08-12 18:53:30 +05:30
committed by GitHub
parent b1da3dc7cf
commit 66db9a0cc1
16 changed files with 148 additions and 94 deletions

View File

@@ -1,14 +0,0 @@
import { mapGetters } from 'vuex';
export default {
computed: {
...mapGetters({
accountId: 'getCurrentAccountId',
}),
},
methods: {
addAccountScoping(url) {
return `/app/accounts/${this.accountId}/${url}`;
},
},
};

View File

@@ -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'
);
});
});