diff options
Diffstat (limited to 'spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js b/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js index 4d566dbec0c..6d8f895a185 100644 --- a/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js +++ b/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js @@ -16,14 +16,18 @@ import { AWS_TEMPLATES_BASE_URL, AWS_EASY_BUTTONS, } from '~/vue_shared/components/runner_instructions/constants'; -import RunnerAwsInstructions from '~/vue_shared/components/runner_instructions/instructions/runner_aws_instructions.vue'; import { __ } from '~/locale'; +import RunnerAwsInstructions from '~/vue_shared/components/runner_instructions/instructions/runner_aws_instructions.vue'; +import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue'; + jest.mock('~/lib/utils/url_utility', () => ({ ...jest.requireActual('~/lib/utils/url_utility'), visitUrl: jest.fn(), })); +const mockRegistrationToken = 'MY_TOKEN'; + describe('RunnerAwsInstructions', () => { let wrapper; @@ -31,6 +35,7 @@ describe('RunnerAwsInstructions', () => { const findEasyButtons = () => wrapper.findAllComponents(GlFormRadio); const findEasyButtonAt = (i) => findEasyButtons().at(i); const findLink = () => wrapper.findComponent(GlLink); + const findModalCopyButton = () => wrapper.findComponent(ModalCopyButton); const findOkButton = () => wrapper .findAllComponents(GlButton) @@ -38,8 +43,12 @@ describe('RunnerAwsInstructions', () => { .at(0); const findCloseButton = () => wrapper.findByText(__('Close')); - const createComponent = () => { + const createComponent = ({ props = {} } = {}) => { wrapper = shallowMountExtended(RunnerAwsInstructions, { + propsData: { + registrationToken: mockRegistrationToken, + ...props, + }, stubs: { GlSprintf, }, @@ -109,6 +118,22 @@ describe('RunnerAwsInstructions', () => { expect(findLink().attributes('href')).toBe(AWS_README_URL); }); + it('shows registration token and copy button', () => { + const token = wrapper.findByText(mockRegistrationToken); + + expect(token.exists()).toBe(true); + expect(token.element.tagName).toBe('PRE'); + + expect(findModalCopyButton().props('text')).toBe(mockRegistrationToken); + }); + + it('does not show registration token and copy button when token is not present', () => { + createComponent({ props: { registrationToken: null } }); + + expect(wrapper.find('pre').exists()).toBe(false); + expect(findModalCopyButton().exists()).toBe(false); + }); + it('triggers the modal to close', () => { findCloseButton().vm.$emit('click'); |