blob: 3a5fb99fdf1166b3fc10726533ec3f058f09bcbd (
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
|
import { shallowMount } from '@vue/test-utils';
import AlertManagementEmptyState from '~/alert_management/components/alert_management_empty_state.vue';
import AlertManagementList from '~/alert_management/components/alert_management_list_wrapper.vue';
import AlertManagementTable from '~/alert_management/components/alert_management_table.vue';
import defaultProvideValues from '../mocks/alerts_provide_config.json';
describe('AlertManagementList', () => {
let wrapper;
function mountComponent({ provide = {} } = {}) {
wrapper = shallowMount(AlertManagementList, {
provide: {
...defaultProvideValues,
...provide,
},
});
}
beforeEach(() => {
mountComponent();
});
afterEach(() => {
if (wrapper) {
wrapper.destroy();
}
});
describe('Alert List Wrapper', () => {
it('should show the empty state when alerts are not enabled', () => {
expect(wrapper.findComponent(AlertManagementEmptyState).exists()).toBe(true);
expect(wrapper.findComponent(AlertManagementTable).exists()).toBe(false);
});
it('should show the alerts table when alerts are enabled', () => {
mountComponent({
provide: {
alertManagementEnabled: true,
},
});
expect(wrapper.findComponent(AlertManagementEmptyState).exists()).toBe(false);
expect(wrapper.findComponent(AlertManagementTable).exists()).toBe(true);
});
});
});
|