Bug: Fix account_id in URLs (#894)
* Bug: Fix account_id in URLs * Fix accountMixin specs
This commit is contained in:
parent
b7a583b2c4
commit
efc59bb43f
14 changed files with 43 additions and 42 deletions
|
@ -1,10 +1,10 @@
|
|||
import auth from '../api/auth';
|
||||
import { mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
accountId() {
|
||||
return auth.getCurrentUser().account_id;
|
||||
},
|
||||
...mapGetters({
|
||||
accountId: 'getCurrentAccountId',
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
addAccountScoping(url) {
|
||||
|
|
|
@ -1,33 +1,40 @@
|
|||
import { createWrapper } from '@vue/test-utils';
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||
import accountMixin from '../account';
|
||||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
|
||||
jest.mock('../../api/auth', () => ({
|
||||
getCurrentUser: () => ({ account_id: 1 }),
|
||||
}));
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
|
||||
describe('accountMixin', () => {
|
||||
test('set accountId properly', () => {
|
||||
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 Constructor = Vue.extend(Component);
|
||||
const vm = new Constructor().$mount();
|
||||
const wrapper = createWrapper(vm);
|
||||
const wrapper = shallowMount(Component, { store, localVue });
|
||||
expect(wrapper.vm.accountId).toBe(1);
|
||||
});
|
||||
|
||||
test('returns current url', () => {
|
||||
it('returns current url', () => {
|
||||
const Component = {
|
||||
render() {},
|
||||
title: 'TestComponent',
|
||||
mixins: [accountMixin],
|
||||
};
|
||||
const Constructor = Vue.extend(Component);
|
||||
const vm = new Constructor().$mount();
|
||||
const wrapper = createWrapper(vm);
|
||||
|
||||
const wrapper = shallowMount(Component, { store, localVue });
|
||||
expect(wrapper.vm.addAccountScoping('settings/inboxes/new')).toBe(
|
||||
'/app/accounts/1/settings/inboxes/new'
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue