diff options
Diffstat (limited to 'spec/frontend/members')
-rw-r--r-- | spec/frontend/members/index_spec.js | 8 | ||||
-rw-r--r-- | spec/frontend/members/mock_data.js | 13 | ||||
-rw-r--r-- | spec/frontend/members/utils_spec.js | 13 |
3 files changed, 18 insertions, 16 deletions
diff --git a/spec/frontend/members/index_spec.js b/spec/frontend/members/index_spec.js index 751c4674a60..b07534ae4ed 100644 --- a/spec/frontend/members/index_spec.js +++ b/spec/frontend/members/index_spec.js @@ -2,7 +2,7 @@ import { createWrapper } from '@vue/test-utils'; import MembersApp from '~/members/components/app.vue'; import { MEMBER_TYPES } from '~/members/constants'; import { initMembersApp } from '~/members/index'; -import { membersJsonString, members, paginationJsonString, pagination } from './mock_data'; +import { members, pagination, dataAttribute } from './mock_data'; describe('initMembersApp', () => { let el; @@ -23,11 +23,7 @@ describe('initMembersApp', () => { beforeEach(() => { el = document.createElement('div'); - el.setAttribute('data-members', membersJsonString); - el.setAttribute('data-pagination', paginationJsonString); - el.setAttribute('data-source-id', '234'); - el.setAttribute('data-can-manage-members', 'true'); - el.setAttribute('data-member-path', '/groups/foo-bar/-/group_members/:id'); + el.setAttribute('data-members-data', dataAttribute); window.gon = { current_user_id: 123 }; }); diff --git a/spec/frontend/members/mock_data.js b/spec/frontend/members/mock_data.js index 6e1ee979839..d0a7c36349b 100644 --- a/spec/frontend/members/mock_data.js +++ b/spec/frontend/members/mock_data.js @@ -80,13 +80,13 @@ export const inheritedMember = { ...member, isDirectMember: false }; export const member2faEnabled = { ...member, user: { ...member.user, twoFactorEnabled: true } }; -export const paginationJsonString = JSON.stringify({ +export const paginationData = { current_page: 1, per_page: 5, total_items: 10, param_name: 'page', params: { search_groups: null }, -}); +}; export const pagination = { currentPage: 1, @@ -95,3 +95,12 @@ export const pagination = { paramName: 'page', params: { search_groups: null }, }; + +export const dataAttribute = JSON.stringify({ + members, + pagination: paginationData, + source_id: 234, + can_manage_members: true, + member_path: '/groups/foo-bar/-/group_members/:id', + ldap_override_path: '/groups/ldap-group/-/group_members/:id/override', +}); diff --git a/spec/frontend/members/utils_spec.js b/spec/frontend/members/utils_spec.js index 91e99876238..72696979722 100644 --- a/spec/frontend/members/utils_spec.js +++ b/spec/frontend/members/utils_spec.js @@ -20,10 +20,9 @@ import { member2faEnabled, group, invite, - membersJsonString, members, - paginationJsonString, pagination, + dataAttribute, } from './mock_data'; const IS_CURRENT_USER_ID = 123; @@ -260,22 +259,20 @@ describe('Members Utils', () => { beforeEach(() => { el = document.createElement('div'); - el.setAttribute('data-members', membersJsonString); - el.setAttribute('data-pagination', paginationJsonString); - el.setAttribute('data-source-id', '234'); - el.setAttribute('data-can-manage-members', 'true'); + el.setAttribute('data-members-data', dataAttribute); }); afterEach(() => { el = null; }); - it('correctly parses the data attributes', () => { - expect(parseDataAttributes(el)).toEqual({ + it('correctly parses the data attribute', () => { + expect(parseDataAttributes(el)).toMatchObject({ members, pagination, sourceId: 234, canManageMembers: true, + memberPath: '/groups/foo-bar/-/group_members/:id', }); }); }); |