diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js')
-rw-r--r-- | spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js b/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js index 8174ba5c693..df98312b498 100644 --- a/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js +++ b/spec/frontend/snippets/components/snippet_blob_actions_edit_spec.js @@ -1,6 +1,7 @@ -import { shallowMount } from '@vue/test-utils'; import { times } from 'lodash'; import { nextTick } from 'vue'; +import { GlFormGroup } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; import SnippetBlobActionsEdit from '~/snippets/components/snippet_blob_actions_edit.vue'; import SnippetBlobEdit from '~/snippets/components/snippet_blob_edit.vue'; import { @@ -8,6 +9,7 @@ import { SNIPPET_BLOB_ACTION_CREATE, SNIPPET_BLOB_ACTION_MOVE, } from '~/snippets/constants'; +import { s__ } from '~/locale'; import { testEntries, createBlobFromTestEntry } from '../test_utils'; const TEST_BLOBS = [ @@ -29,7 +31,7 @@ describe('snippets/components/snippet_blob_actions_edit', () => { }); }; - const findLabel = () => wrapper.find('label'); + const findLabel = () => wrapper.findComponent(GlFormGroup); const findBlobEdits = () => wrapper.findAll(SnippetBlobEdit); const findBlobsData = () => findBlobEdits().wrappers.map((x) => ({ @@ -65,7 +67,7 @@ describe('snippets/components/snippet_blob_actions_edit', () => { }); it('renders label', () => { - expect(findLabel().text()).toBe('Files'); + expect(findLabel().attributes('label')).toBe('Files'); }); it(`renders delete button (show=true)`, () => { @@ -280,4 +282,32 @@ describe('snippets/components/snippet_blob_actions_edit', () => { expect(findAddButton().props('disabled')).toBe(true); }); }); + + describe('isValid prop', () => { + const validationMessage = s__( + "Snippets|Snippets can't contain empty files. Ensure all files have content, or delete them.", + ); + + describe('when not present', () => { + it('sets the label validation state to true', () => { + createComponent(); + + const label = findLabel(); + + expect(Boolean(label.attributes('state'))).toEqual(true); + expect(label.attributes('invalid-feedback')).toEqual(validationMessage); + }); + }); + + describe('when present', () => { + it('sets the label validation state to the value', () => { + createComponent({ isValid: false }); + + const label = findLabel(); + + expect(Boolean(label.attributes('state'))).toEqual(false); + expect(label.attributes('invalid-feedback')).toEqual(validationMessage); + }); + }); + }); }); |