Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-07 03:11:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-07 03:11:11 +0300
commitd4f8f25db649b973f1ae344cb0f8a407862d106b (patch)
treef71f2d2243dc768a1ec44e79556d8020bff51dc7 /spec/frontend/pipelines/tokens
parent5f0e3773e9695fd0c9e92ea9180c8a1f5cfaa5c5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipelines/tokens')
-rw-r--r--spec/frontend/pipelines/tokens/pipeline_trigger_author_token_spec.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/frontend/pipelines/tokens/pipeline_trigger_author_token_spec.js b/spec/frontend/pipelines/tokens/pipeline_trigger_author_token_spec.js
new file mode 100644
index 00000000000..56aba62ede2
--- /dev/null
+++ b/spec/frontend/pipelines/tokens/pipeline_trigger_author_token_spec.js
@@ -0,0 +1,63 @@
+import { GlFilteredSearchToken, GlFilteredSearchSuggestion } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import PipelineTriggerAuthorToken from '~/pipelines/components/tokens/pipeline_trigger_author_token.vue';
+import { users } from '../mock_data';
+
+describe('Pipeline Trigger Author Token', () => {
+ let wrapper;
+
+ const findFilteredSearchToken = () => wrapper.find(GlFilteredSearchToken);
+ const findAllFilteredSearchSuggestions = () => wrapper.findAll(GlFilteredSearchSuggestion);
+
+ const stubs = {
+ GlFilteredSearchToken: {
+ template: `<div><slot name="suggestions"></slot></div>`,
+ },
+ };
+
+ const defaultProps = {
+ config: {
+ type: 'username',
+ icon: 'user',
+ title: 'Trigger author',
+ dataType: 'username',
+ unique: true,
+ triggerAuthors: users,
+ },
+ };
+
+ const createComponent = (props = {}, options) => {
+ wrapper = shallowMount(PipelineTriggerAuthorToken, {
+ propsData: {
+ ...props,
+ ...defaultProps,
+ },
+ ...options,
+ });
+ };
+
+ beforeEach(() => {
+ createComponent({ value: { data: '' } });
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ it('passes config correctly', () => {
+ expect(findFilteredSearchToken().props('config')).toEqual(defaultProps.config);
+ });
+
+ describe('shows trigger authors correctly', () => {
+ it('renders all trigger authors', () => {
+ createComponent({ value: { data: '' } }, { stubs });
+ expect(findAllFilteredSearchSuggestions()).toHaveLength(7);
+ });
+
+ it('renders only the trigger author searched for', () => {
+ createComponent({ value: { data: 'root' } }, { stubs });
+ expect(findAllFilteredSearchSuggestions()).toHaveLength(2);
+ });
+ });
+});