2020-08-28 15:10:21 +00:00
|
|
|
import { GlLink, GlSprintf } from '@gitlab/ui';
|
2021-02-14 18:09:20 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2022-01-25 15:12:32 +00:00
|
|
|
import { nextTick } from 'vue';
|
2020-08-28 15:10:21 +00:00
|
|
|
import NewCluster from '~/clusters/components/new_cluster.vue';
|
2022-05-05 12:08:03 +00:00
|
|
|
import { helpPagePath } from '~/helpers/help_page_helper';
|
2020-08-28 15:10:21 +00:00
|
|
|
|
|
|
|
describe('NewCluster', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2022-01-25 15:12:32 +00:00
|
|
|
const createWrapper = async () => {
|
2022-05-05 12:08:03 +00:00
|
|
|
wrapper = shallowMount(NewCluster, { stubs: { GlLink, GlSprintf } });
|
2022-01-25 15:12:32 +00:00
|
|
|
await nextTick();
|
2020-08-28 15:10:21 +00:00
|
|
|
};
|
|
|
|
|
2022-08-11 18:11:57 +00:00
|
|
|
const findDescription = () => wrapper.findComponent(GlSprintf);
|
2020-08-28 15:10:21 +00:00
|
|
|
|
2022-08-11 18:11:57 +00:00
|
|
|
const findLink = () => wrapper.findComponent(GlLink);
|
2020-08-28 15:10:21 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
return createWrapper();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the cluster component correctly', () => {
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the correct information text', () => {
|
2022-03-16 18:08:16 +00:00
|
|
|
expect(findDescription().text()).toContain('Enter details about your cluster.');
|
2020-08-28 15:10:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders a valid help link set by the backend', () => {
|
2022-05-05 12:08:03 +00:00
|
|
|
expect(findLink().attributes('href')).toBe(
|
|
|
|
helpPagePath('user/project/clusters/add_existing_cluster'),
|
|
|
|
);
|
2020-08-28 15:10:21 +00:00
|
|
|
});
|
|
|
|
});
|