debian-mirror-gitlab/spec/frontend/groups/members/utils_spec.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import { membersJsonString, membersParsed } from './mock_data';
import {
parseDataAttributes,
memberRequestFormatter,
groupLinkRequestFormatter,
} from '~/groups/members/utils';
describe('group member utils', () => {
describe('parseDataAttributes', () => {
let el;
beforeEach(() => {
el = document.createElement('div');
el.setAttribute('data-members', membersJsonString);
el.setAttribute('data-group-id', '234');
2021-02-22 17:27:13 +05:30
el.setAttribute('data-can-manage-members', 'true');
2021-01-03 14:25:43 +05:30
});
afterEach(() => {
el = null;
});
it('correctly parses the data attributes', () => {
expect(parseDataAttributes(el)).toEqual({
members: membersParsed,
sourceId: 234,
2021-02-22 17:27:13 +05:30
canManageMembers: true,
2021-01-03 14:25:43 +05:30
});
});
});
describe('memberRequestFormatter', () => {
it('returns expected format', () => {
expect(
memberRequestFormatter({
accessLevel: 50,
expires_at: '2020-10-16',
}),
).toEqual({ group_member: { access_level: 50, expires_at: '2020-10-16' } });
});
});
describe('groupLinkRequestFormatter', () => {
it('returns expected format', () => {
expect(
groupLinkRequestFormatter({
accessLevel: 50,
expires_at: '2020-10-16',
}),
).toEqual({ group_link: { group_access: 50, expires_at: '2020-10-16' } });
});
});
});