diff options
Diffstat (limited to 'spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js')
-rw-r--r-- | spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js new file mode 100644 index 00000000000..5d37f059161 --- /dev/null +++ b/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js @@ -0,0 +1,48 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlButton } from '@gitlab/ui'; +import CiVariablePopover from '~/ci_variable_list/components/ci_variable_popover.vue'; +import mockData from '../services/mock_data'; + +describe('Ci Variable Popover', () => { + let wrapper; + + const defaultProps = { + target: 'ci-variable-value-22', + value: mockData.mockPemCert, + tooltipText: 'Copy value', + }; + + const createComponent = (props = defaultProps) => { + wrapper = shallowMount(CiVariablePopover, { + propsData: { ...props }, + }); + }; + + const findButton = () => wrapper.find(GlButton); + + beforeEach(() => { + createComponent(); + }); + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + it('displays max count plus ... when character count is over 95', () => { + expect(wrapper.text()).toHaveLength(98); + }); + + it('copies full value to clipboard', () => { + expect(findButton().attributes('data-clipboard-text')).toEqual(mockData.mockPemCert); + }); + + it('displays full value when count is less than max count', () => { + createComponent({ + target: 'ci-variable-value-22', + value: 'test_variable_value', + tooltipText: 'Copy value', + }); + expect(wrapper.text()).toEqual('test_variable_value'); + }); +}); |