blob: 82a5c5f624a2532ed1165fe66f838a4e567b4987 (
plain)
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
|
import { GlButton, GlAlert } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import SubmitChangesError from '~/static_site_editor/components/submit_changes_error.vue';
import { submitChangesError as error } from '../mock_data';
describe('Submit Changes Error', () => {
let wrapper;
const buildWrapper = (propsData = {}) => {
wrapper = shallowMount(SubmitChangesError, {
propsData: {
...propsData,
},
stubs: {
GlAlert,
},
});
};
const findRetryButton = () => wrapper.find(GlButton);
const findAlert = () => wrapper.find(GlAlert);
beforeEach(() => {
buildWrapper({ error });
});
afterEach(() => {
wrapper.destroy();
});
it('renders error message', () => {
expect(findAlert().text()).toContain(error);
});
it('emits dismiss event when alert emits dismiss event', () => {
findAlert().vm.$emit('dismiss');
expect(wrapper.emitted('dismiss')).toHaveLength(1);
});
it('emits retry event when retry button is clicked', () => {
findRetryButton().vm.$emit('click');
expect(wrapper.emitted('retry')).toHaveLength(1);
});
});
|