diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 21:08:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 21:08:53 +0300 |
commit | 5b62f8e3ee531f63ce3c49cae03e2a618ba51615 (patch) | |
tree | 2d2553232fe0663957ee4d1054211cc71cb07679 /spec/frontend/deploy_keys | |
parent | cdb41961fd2bc233d36c5b30f89d087c2efa9818 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/deploy_keys')
-rw-r--r-- | spec/frontend/deploy_keys/components/key_spec.js | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/spec/frontend/deploy_keys/components/key_spec.js b/spec/frontend/deploy_keys/components/key_spec.js index 5f20d4ad542..3c4fa2a6de6 100644 --- a/spec/frontend/deploy_keys/components/key_spec.js +++ b/spec/frontend/deploy_keys/components/key_spec.js @@ -1,9 +1,10 @@ import { mount } from '@vue/test-utils'; import { nextTick } from 'vue'; import data from 'test_fixtures/deploy_keys/keys.json'; +import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import key from '~/deploy_keys/components/key.vue'; import DeployKeysStore from '~/deploy_keys/store'; -import { getTimeago } from '~/lib/utils/datetime_utility'; +import { getTimeago, formatDate } from '~/lib/utils/datetime_utility'; describe('Deploy keys key', () => { let wrapper; @@ -18,6 +19,9 @@ describe('Deploy keys key', () => { endpoint: 'https://test.host/dummy/endpoint', ...propsData, }, + directives: { + GlTooltip: createMockDirective('gl-tooltip'), + }, }); }; @@ -43,6 +47,33 @@ describe('Deploy keys key', () => { ); }); + it('renders human friendly expiration date', () => { + const expiresAt = new Date(); + createComponent({ + deployKey: { ...deployKey, expires_at: expiresAt }, + }); + + expect(findTextAndTrim('.key-expires-at')).toBe(`${getTimeago().format(expiresAt)}`); + }); + it('shows tooltip for expiration date', () => { + const expiresAt = new Date(); + createComponent({ + deployKey: { ...deployKey, expires_at: expiresAt }, + }); + + const expiryComponent = wrapper.find('[data-testid="expires-at-tooltip"]'); + const tooltip = getBinding(expiryComponent.element, 'gl-tooltip'); + expect(tooltip).toBeDefined(); + expect(expiryComponent.attributes('title')).toBe(`${formatDate(expiresAt)}`); + }); + it('renders never when no expiration date', () => { + createComponent({ + deployKey: { ...deployKey, expires_at: null }, + }); + + expect(wrapper.find('[data-testid="expires-never"]').exists()).toBe(true); + }); + it('shows pencil button for editing', () => { createComponent({ deployKey }); |