2020-11-24 15:15:51 +05:30
|
|
|
import { createWrapper } from '@vue/test-utils';
|
2021-09-04 01:27:46 +05:30
|
|
|
import MembersTabs from '~/members/components/members_tabs.vue';
|
2021-04-29 21:17:54 +05:30
|
|
|
import { MEMBER_TYPES } from '~/members/constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { initMembersApp } from '~/members/index';
|
2021-06-08 01:23:25 +05:30
|
|
|
import { members, pagination, dataAttribute } from './mock_data';
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe('initMembersApp', () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
let el;
|
|
|
|
let vm;
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const setup = () => {
|
2021-03-11 19:13:27 +05:30
|
|
|
vm = initMembersApp(el, {
|
2021-09-04 01:27:46 +05:30
|
|
|
[MEMBER_TYPES.user]: {
|
|
|
|
tableFields: ['account'],
|
|
|
|
tableAttrs: { table: { 'data-qa-selector': 'members_list' } },
|
|
|
|
tableSortableFields: ['account'],
|
|
|
|
requestFormatter: () => ({}),
|
|
|
|
filteredSearchBar: { show: false },
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
2020-11-24 15:15:51 +05:30
|
|
|
wrapper = createWrapper(vm);
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
el = document.createElement('div');
|
2022-07-23 23:45:48 +05:30
|
|
|
el.dataset.membersData = dataAttribute;
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
window.gon = { current_user_id: 123 };
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
el = null;
|
|
|
|
});
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it('renders `MembersTabs`', () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
setup();
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(wrapper.findComponent(MembersTabs).exists()).toBe(true);
|
2020-11-24 15:15:51 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('parses and sets `members` in Vuex store', () => {
|
|
|
|
setup();
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(vm.$store.state[MEMBER_TYPES.user].members).toEqual(members);
|
2020-11-24 15:15:51 +05:30
|
|
|
});
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it('parses and sets `pagination` in Vuex store', () => {
|
|
|
|
setup();
|
|
|
|
|
|
|
|
expect(vm.$store.state[MEMBER_TYPES.user].pagination).toEqual(pagination);
|
|
|
|
});
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it('sets `tableFields` in Vuex store', () => {
|
|
|
|
setup();
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(vm.$store.state[MEMBER_TYPES.user].tableFields).toEqual(['account']);
|
2021-01-03 14:25:43 +05:30
|
|
|
});
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
it('sets `tableAttrs` in Vuex store', () => {
|
|
|
|
setup();
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(vm.$store.state[MEMBER_TYPES.user].tableAttrs).toEqual({
|
|
|
|
table: { 'data-qa-selector': 'members_list' },
|
|
|
|
});
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it('sets `tableSortableFields` in Vuex store', () => {
|
|
|
|
setup();
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(vm.$store.state[MEMBER_TYPES.user].tableSortableFields).toEqual(['account']);
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it('sets `requestFormatter` in Vuex store', () => {
|
|
|
|
setup();
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(vm.$store.state[MEMBER_TYPES.user].requestFormatter()).toEqual({});
|
2021-01-03 14:25:43 +05:30
|
|
|
});
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it('sets `filteredSearchBar` in Vuex store', () => {
|
|
|
|
setup();
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(vm.$store.state[MEMBER_TYPES.user].filteredSearchBar).toEqual({ show: false });
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it('sets `memberPath` in Vuex store', () => {
|
|
|
|
setup();
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(vm.$store.state[MEMBER_TYPES.user].memberPath).toBe(
|
|
|
|
'/groups/foo-bar/-/group_members/:id',
|
|
|
|
);
|
2021-01-03 14:25:43 +05:30
|
|
|
});
|
2020-11-24 15:15:51 +05:30
|
|
|
});
|