1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
import { namespaces } from 'jest/vue_shared/components/namespace_select/mock_data';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import TransferProjectForm from '~/projects/settings/components/transfer_project_form.vue';
import NamespaceSelect from '~/vue_shared/components/namespace_select/namespace_select.vue';
import ConfirmDanger from '~/vue_shared/components/confirm_danger/confirm_danger.vue';
describe('Transfer project form', () => {
let wrapper;
const confirmButtonText = 'Confirm';
const confirmationPhrase = 'You must construct additional pylons!';
const createComponent = () =>
shallowMountExtended(TransferProjectForm, {
propsData: {
namespaces,
confirmButtonText,
confirmationPhrase,
},
});
const findNamespaceSelect = () => wrapper.findComponent(NamespaceSelect);
const findConfirmDanger = () => wrapper.findComponent(ConfirmDanger);
beforeEach(() => {
wrapper = createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('renders the namespace selector', () => {
expect(findNamespaceSelect().exists()).toBe(true);
});
it('renders the confirm button', () => {
expect(findConfirmDanger().exists()).toBe(true);
});
it('disables the confirm button by default', () => {
expect(findConfirmDanger().attributes('disabled')).toBe('true');
});
describe('with a selected namespace', () => {
const [selectedItem] = namespaces.group;
beforeEach(() => {
findNamespaceSelect().vm.$emit('select', selectedItem);
});
it('emits the `selectNamespace` event when a namespace is selected', () => {
const args = [selectedItem.id];
expect(wrapper.emitted('selectNamespace')).toEqual([args]);
});
it('enables the confirm button', () => {
expect(findConfirmDanger().attributes('disabled')).toBeUndefined();
});
it('clicking the confirm button emits the `confirm` event', () => {
findConfirmDanger().vm.$emit('confirm');
expect(wrapper.emitted('confirm')).toBeDefined();
});
});
});
|