2020-09-14 08:09:34 -04:00
|
|
|
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;
|
|
|
|
|
|
|
|
const createComponent = (props = { users: [] }) => {
|
|
|
|
wrapper = shallowMount(IssuableAssignees, {
|
|
|
|
provide: {
|
|
|
|
rootPath: '',
|
|
|
|
},
|
|
|
|
propsData: { ...props },
|
|
|
|
});
|
|
|
|
};
|
|
|
|
const findUncollapsedAssigneeList = () => wrapper.find(UncollapsedAssigneeList);
|
|
|
|
const findEmptyAssignee = () => wrapper.find('[data-testid="none"]');
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when no assignees are present', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
2020-11-19 04:09:38 -05:00
|
|
|
it('renders "None - assign yourself"', () => {
|
|
|
|
expect(findEmptyAssignee().text()).toBe('None - assign yourself');
|
2020-09-14 08:09:34 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when assignees are present', () => {
|
|
|
|
it('renders UncollapsedAssigneesList', () => {
|
|
|
|
createComponent({ users: [{ id: 1 }] });
|
|
|
|
|
|
|
|
expect(findUncollapsedAssigneeList().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
2020-11-19 04:09:38 -05:00
|
|
|
|
|
|
|
describe('when clicking "assign yourself"', () => {
|
|
|
|
it('emits "assign-self"', () => {
|
|
|
|
createComponent();
|
|
|
|
wrapper.find('[data-testid="assign-yourself"]').vm.$emit('click');
|
|
|
|
expect(wrapper.emitted('assign-self')).toHaveLength(1);
|
|
|
|
});
|
|
|
|
});
|
2020-09-14 08:09:34 -04:00
|
|
|
});
|