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-04 21:10:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-04 21:10:20 +0300
commit9bbcab8301ed38576debcb6a7f07f99005ff805a (patch)
tree20e348b90c8fc27db66a68d6a87546448590f31b /spec/frontend
parent39a548dd06b8ddcc0d2acb7832460f5fe1876521 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/pipelines/pipelines_table_spec.js66
-rw-r--r--spec/frontend/users_select/utils_spec.js33
2 files changed, 99 insertions, 0 deletions
diff --git a/spec/frontend/pipelines/pipelines_table_spec.js b/spec/frontend/pipelines/pipelines_table_spec.js
new file mode 100644
index 00000000000..b0ab250dd16
--- /dev/null
+++ b/spec/frontend/pipelines/pipelines_table_spec.js
@@ -0,0 +1,66 @@
+import { mount } from '@vue/test-utils';
+import PipelinesTable from '~/pipelines/components/pipelines_table.vue';
+
+describe('Pipelines Table', () => {
+ let pipeline;
+ let wrapper;
+
+ const jsonFixtureName = 'pipelines/pipelines.json';
+
+ const defaultProps = {
+ pipelines: [],
+ autoDevopsHelpPath: 'foo',
+ viewType: 'root',
+ };
+
+ const createComponent = (props = defaultProps) => {
+ wrapper = mount(PipelinesTable, {
+ propsData: props,
+ });
+ };
+ const findRows = () => wrapper.findAll('.commit.gl-responsive-table-row');
+
+ preloadFixtures(jsonFixtureName);
+
+ beforeEach(() => {
+ const { pipelines } = getJSONFixture(jsonFixtureName);
+ pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
+
+ createComponent();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ describe('table', () => {
+ it('should render a table', () => {
+ expect(wrapper.classes()).toContain('ci-table');
+ });
+
+ it('should render table head with correct columns', () => {
+ expect(wrapper.find('.table-section.js-pipeline-status').text()).toEqual('Status');
+
+ expect(wrapper.find('.table-section.js-pipeline-info').text()).toEqual('Pipeline');
+
+ expect(wrapper.find('.table-section.js-pipeline-commit').text()).toEqual('Commit');
+
+ expect(wrapper.find('.table-section.js-pipeline-stages').text()).toEqual('Stages');
+ });
+ });
+
+ describe('without data', () => {
+ it('should render an empty table', () => {
+ expect(findRows()).toHaveLength(0);
+ });
+ });
+
+ describe('with data', () => {
+ it('should render rows', () => {
+ createComponent({ pipelines: [pipeline], autoDevopsHelpPath: 'foo', viewType: 'root' });
+
+ expect(findRows()).toHaveLength(1);
+ });
+ });
+});
diff --git a/spec/frontend/users_select/utils_spec.js b/spec/frontend/users_select/utils_spec.js
new file mode 100644
index 00000000000..a09935d8a04
--- /dev/null
+++ b/spec/frontend/users_select/utils_spec.js
@@ -0,0 +1,33 @@
+import $ from 'jquery';
+import { getAjaxUsersSelectOptions, getAjaxUsersSelectParams } from '~/users_select/utils';
+
+const options = {
+ fooBar: 'baz',
+ activeUserId: 1,
+};
+
+describe('getAjaxUsersSelectOptions', () => {
+ it('returns options built from select data attributes', () => {
+ const $select = $('<select />', { 'data-foo-bar': 'baz', 'data-user-id': 1 });
+
+ expect(
+ getAjaxUsersSelectOptions($select, { fooBar: 'fooBar', activeUserId: 'user-id' }),
+ ).toEqual(options);
+ });
+});
+
+describe('getAjaxUsersSelectParams', () => {
+ it('returns query parameters built from provided options', () => {
+ expect(
+ getAjaxUsersSelectParams(options, {
+ foo_bar: 'fooBar',
+ active_user_id: 'activeUserId',
+ non_existent_key: 'nonExistentKey',
+ }),
+ ).toEqual({
+ foo_bar: 'baz',
+ active_user_id: 1,
+ non_existent_key: null,
+ });
+ });
+});