debian-mirror-gitlab/spec/frontend/sidebar/issuable_assignees_spec.js

60 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-11-24 15:15:51 +05:30
import { shallowMount } from '@vue/test-utils';
import IssuableAssignees from '~/sidebar/components/assignees/issuable_assignees.vue';
import UncollapsedAssigneeList from '~/sidebar/components/assignees/uncollapsed_assignee_list.vue';
describe('IssuableAssignees', () => {
let wrapper;
2021-04-29 21:17:54 +05:30
const createComponent = (props = {}) => {
2020-11-24 15:15:51 +05:30
wrapper = shallowMount(IssuableAssignees, {
provide: {
rootPath: '',
},
2021-04-29 21:17:54 +05:30
propsData: {
users: [],
2022-10-11 01:57:18 +05:30
editable: true,
2021-04-29 21:17:54 +05:30
...props,
},
2020-11-24 15:15:51 +05:30
});
};
2022-11-25 23:54:43 +05:30
const findUncollapsedAssigneeList = () => wrapper.findComponent(UncollapsedAssigneeList);
2020-11-24 15:15:51 +05:30
const findEmptyAssignee = () => wrapper.find('[data-testid="none"]');
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('when no assignees are present', () => {
2022-10-11 01:57:18 +05:30
it.each`
signedIn | editable | message
${true} | ${true} | ${'None - assign yourself'}
${true} | ${false} | ${'None'}
${false} | ${true} | ${'None'}
${false} | ${false} | ${'None'}
`(
'renders "$message" when signedIn is $signedIn and editable is $editable',
({ signedIn, editable, message }) => {
createComponent({ signedIn, editable });
expect(findEmptyAssignee().text()).toBe(message);
},
);
2020-11-24 15:15:51 +05:30
});
describe('when assignees are present', () => {
it('renders UncollapsedAssigneesList', () => {
createComponent({ users: [{ id: 1 }] });
expect(findUncollapsedAssigneeList().exists()).toBe(true);
});
});
2021-02-22 17:27:13 +05:30
describe('when clicking "assign yourself"', () => {
it('emits "assign-self"', () => {
2021-04-29 21:17:54 +05:30
createComponent({ signedIn: true });
2021-02-22 17:27:13 +05:30
wrapper.find('[data-testid="assign-yourself"]').vm.$emit('click');
expect(wrapper.emitted('assign-self')).toHaveLength(1);
});
});
2020-11-24 15:15:51 +05:30
});