blob: eb05b1f184acbef29c1a1e86a6df84a9d53b2aae (
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
|
import { GlModal } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import CreateDashboardModal from '~/monitoring/components/create_dashboard_modal.vue';
describe('Create dashboard modal', () => {
let wrapper;
const defaultProps = {
modalId: 'id',
projectPath: 'https://localhost/',
addDashboardDocumentationPath: 'https://link/to/docs',
};
const findDocsButton = () => wrapper.find('[data-testid="create-dashboard-modal-docs-button"]');
const findRepoButton = () => wrapper.find('[data-testid="create-dashboard-modal-repo-button"]');
const createWrapper = (props = {}, options = {}) => {
wrapper = shallowMount(CreateDashboardModal, {
propsData: { ...defaultProps, ...props },
stubs: {
GlModal,
},
...options,
});
};
beforeEach(() => {
createWrapper();
});
it('has button that links to the project url', async () => {
findRepoButton().trigger('click');
await nextTick();
expect(findRepoButton().exists()).toBe(true);
expect(findRepoButton().attributes('href')).toBe(defaultProps.projectPath);
});
it('has button that links to the docs', () => {
expect(findDocsButton().exists()).toBe(true);
expect(findDocsButton().attributes('href')).toBe(defaultProps.addDashboardDocumentationPath);
});
});
|