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
69
70
71
72
73
74
|
import { GlAlert, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import component from '~/packages_and_registries/container_registry/explorer/components/details_page/partial_cleanup_alert.vue';
import {
DELETE_ALERT_TITLE,
DELETE_ALERT_LINK_TEXT,
} from '~/packages_and_registries/container_registry/explorer/constants';
describe('Partial Cleanup alert', () => {
let wrapper;
const findAlert = () => wrapper.find(GlAlert);
const findRunLink = () => wrapper.find('[data-testid="run-link"');
const findHelpLink = () => wrapper.find('[data-testid="help-link"');
const mountComponent = () => {
wrapper = shallowMount(component, {
stubs: { GlSprintf },
propsData: {
runCleanupPoliciesHelpPagePath: 'foo',
cleanupPoliciesHelpPagePath: 'bar',
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it(`gl-alert has the correct properties`, () => {
mountComponent();
expect(findAlert().props()).toMatchObject({
title: DELETE_ALERT_TITLE,
variant: 'warning',
});
});
it('has the right text', () => {
mountComponent();
expect(wrapper.text()).toMatchInterpolatedText(DELETE_ALERT_LINK_TEXT);
});
it('contains run link', () => {
mountComponent();
const link = findRunLink();
expect(link.exists()).toBe(true);
expect(link.attributes()).toMatchObject({
href: 'foo',
target: '_blank',
});
});
it('contains help link', () => {
mountComponent();
const link = findHelpLink();
expect(link.exists()).toBe(true);
expect(link.attributes()).toMatchObject({
href: 'bar',
target: '_blank',
});
});
it('GlAlert dismiss event triggers a dismiss event', () => {
mountComponent();
findAlert().vm.$emit('dismiss');
expect(wrapper.emitted('dismiss')).toEqual([[]]);
});
});
|