debian-mirror-gitlab/spec/frontend/terraform/components/empty_state_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-07-09 08:55:56 +05:30
import { GlEmptyState, GlButton } from '@gitlab/ui';
2021-01-29 00:20:46 +05:30
import { shallowMount } from '@vue/test-utils';
import EmptyState from '~/terraform/components/empty_state.vue';
2023-07-09 08:55:56 +05:30
import InitCommandModal from '~/terraform/components/init_command_modal.vue';
2021-01-29 00:20:46 +05:30
describe('EmptyStateComponent', () => {
let wrapper;
const propsData = {
image: '/image/path',
};
2022-05-07 20:08:51 +05:30
const docsUrl = '/help/user/infrastructure/iac/terraform_state';
2021-10-27 15:23:28 +05:30
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
2023-07-09 08:55:56 +05:30
const findButton = () => wrapper.findComponent(GlButton);
const findCopyModal = () => wrapper.findComponent(InitCommandModal);
const findCopyButton = () => wrapper.find('[data-testid="terraform-state-copy-init-command"]');
2021-01-29 00:20:46 +05:30
beforeEach(() => {
2022-06-21 17:19:12 +05:30
wrapper = shallowMount(EmptyState, { propsData });
});
2021-01-29 00:20:46 +05:30
it('should render content', () => {
2022-06-21 17:19:12 +05:30
expect(findEmptyState().props('title')).toBe(
"Your project doesn't have any Terraform state files",
);
2021-01-29 00:20:46 +05:30
});
2021-10-27 15:23:28 +05:30
2023-07-09 08:55:56 +05:30
it('buttons explore documentation should have a link to the GitLab managed Terraform states docs', () => {
expect(findButton().attributes('href')).toBe(docsUrl);
});
describe('copy command button', () => {
it('displays a copy init command button', () => {
expect(findCopyButton().text()).toBe('Copy Terraform init command');
});
it('opens the modal on copy button click', async () => {
await findCopyButton().vm.$emit('click');
expect(findCopyModal().isVisible()).toBe(true);
});
2021-10-27 15:23:28 +05:30
});
2021-01-29 00:20:46 +05:30
});