2020-10-16 08:09:33 -04:00
|
|
|
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { mount } from '@vue/test-utils';
|
2019-07-05 06:14:56 -04:00
|
|
|
import Dropdown from '~/confidential_merge_request/components/dropdown.vue';
|
|
|
|
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
function factory(projects = []) {
|
|
|
|
vm = mount(Dropdown, {
|
|
|
|
propsData: {
|
|
|
|
projects,
|
|
|
|
selectedProject: projects[0],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Confidential merge request project dropdown component', () => {
|
|
|
|
afterEach(() => {
|
|
|
|
vm.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders dropdown items', () => {
|
|
|
|
factory([
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
name: 'test',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
name: 'test',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
2020-10-16 08:09:33 -04:00
|
|
|
expect(vm.findAll(GlDropdownItem).length).toBe(2);
|
2019-07-05 06:14:56 -04:00
|
|
|
});
|
|
|
|
|
2020-10-16 08:09:33 -04:00
|
|
|
it('shows lock icon', () => {
|
|
|
|
factory();
|
|
|
|
|
|
|
|
expect(vm.find(GlDropdown).props('icon')).toBe('lock');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('has dropdown text', () => {
|
|
|
|
factory();
|
2019-07-05 06:14:56 -04:00
|
|
|
|
2020-10-16 08:09:33 -04:00
|
|
|
expect(vm.find(GlDropdown).props('text')).toBe('Select private project');
|
2019-07-05 06:14:56 -04:00
|
|
|
});
|
|
|
|
});
|