debian-mirror-gitlab/spec/frontend/invite_members/utils/member_utils_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-06-20 00:43:36 +05:30
import {
memberName,
triggerExternalAlert,
qualifiesForTasksToBeDone,
} from '~/invite_members/utils/member_utils';
import setWindowLocation from 'helpers/set_window_location_helper';
import { getParameterValues } from '~/lib/utils/url_utility';
jest.mock('~/lib/utils/url_utility');
2022-08-13 15:12:31 +05:30
describe('Member Name', () => {
it.each([
[{ username: '_username_', name: '_name_' }, '_username_'],
[{ username: '_username_' }, '_username_'],
[{ name: '_name_' }, '_name_'],
[{}, undefined],
])(`returns name from supplied member token: %j`, (member, result) => {
expect(memberName(member)).toBe(result);
});
});
2023-06-20 00:43:36 +05:30
describe('Trigger External Alert', () => {
it('returns false', () => {
expect(triggerExternalAlert()).toBe(false);
});
});
describe('Qualifies For Tasks To Be Done', () => {
it.each([
['invite_members_for_task', true],
['blah', false],
])(`returns name from supplied member token: %j`, (value, result) => {
setWindowLocation(`blah/blah?open_modal=${value}`);
getParameterValues.mockImplementation(() => {
return [value];
});
expect(qualifiesForTasksToBeDone()).toBe(result);
});
});