Chatwoot/app/javascript/dashboard/mixins/specs/account.spec.js

43 lines
986 B
JavaScript
Raw Normal View History

import { shallowMount, createLocalVue } from '@vue/test-utils';
2020-04-23 06:51:45 +00:00
import accountMixin from '../account';
import Vuex from 'vuex';
2020-04-23 06:51:45 +00:00
const localVue = createLocalVue();
localVue.use(Vuex);
2020-04-23 06:51:45 +00:00
describe('accountMixin', () => {
let getters;
let store;
beforeEach(() => {
getters = {
getCurrentAccountId: () => 1,
};
store = new Vuex.Store({ getters });
});
it('set accountId properly', () => {
2020-04-23 06:51:45 +00:00
const Component = {
render() {},
title: 'TestComponent',
mixins: [accountMixin],
};
const wrapper = shallowMount(Component, { store, localVue });
2020-04-23 06:51:45 +00:00
expect(wrapper.vm.accountId).toBe(1);
});
it('returns current url', () => {
2020-04-23 06:51:45 +00:00
const Component = {
render() {},
title: 'TestComponent',
mixins: [accountMixin],
};
const wrapper = shallowMount(Component, { store, localVue });
2020-04-23 06:51:45 +00:00
expect(wrapper.vm.addAccountScoping('settings/inboxes/new')).toBe(
'/app/accounts/1/settings/inboxes/new'
);
});
});