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:
Diffstat (limited to 'spec/frontend/registry/components/table_registry_spec.js')
-rw-r--r--spec/frontend/registry/components/table_registry_spec.js77
1 files changed, 66 insertions, 11 deletions
diff --git a/spec/frontend/registry/components/table_registry_spec.js b/spec/frontend/registry/components/table_registry_spec.js
index 021f13feeba..600a7a6ee87 100644
--- a/spec/frontend/registry/components/table_registry_spec.js
+++ b/spec/frontend/registry/components/table_registry_spec.js
@@ -1,12 +1,19 @@
import Vue from 'vue';
+import Vuex from 'vuex';
import tableRegistry from '~/registry/components/table_registry.vue';
-import { mount } from '@vue/test-utils';
+import { mount, createLocalVue } from '@vue/test-utils';
import { repoPropsData } from '../mock_data';
+import * as getters from '~/registry/stores/getters';
const [firstImage, secondImage] = repoPropsData.list;
+const localVue = createLocalVue();
+
+localVue.use(Vuex);
+
describe('table registry', () => {
let wrapper;
+ let store;
const findSelectAllCheckbox = w => w.find('.js-select-all-checkbox > input');
const findSelectCheckboxes = w => w.findAll('.js-select-checkbox > input');
@@ -15,19 +22,31 @@ describe('table registry', () => {
const findPagination = w => w.find('.js-registry-pagination');
const bulkDeletePath = 'path';
+ const mountWithStore = config => mount(tableRegistry, { ...config, store, localVue });
+
beforeEach(() => {
// This is needed due to console.error called by vue to emit a warning that stop the tests
// see https://github.com/vuejs/vue-test-utils/issues/532
Vue.config.silent = true;
- wrapper = mount(tableRegistry, {
+
+ store = new Vuex.Store({
+ state: {
+ isDeleteDisabled: false,
+ },
+ getters,
+ });
+
+ wrapper = mountWithStore({
propsData: {
repo: repoPropsData,
+ canDeleteRepo: true,
},
});
});
afterEach(() => {
Vue.config.silent = false;
+ wrapper.destroy();
});
describe('rendering', () => {
@@ -149,7 +168,6 @@ describe('table registry', () => {
});
describe('pagination', () => {
- let localWrapper = null;
const repo = {
repoPropsData,
pagination: {
@@ -160,7 +178,7 @@ describe('table registry', () => {
};
beforeEach(() => {
- localWrapper = mount(tableRegistry, {
+ wrapper = mount(tableRegistry, {
propsData: {
repo,
},
@@ -168,13 +186,13 @@ describe('table registry', () => {
});
it('should exist', () => {
- const pagination = findPagination(localWrapper);
+ const pagination = findPagination(wrapper);
expect(pagination.exists()).toBe(true);
});
it('should be visible when pagination is needed', () => {
- const pagination = findPagination(localWrapper);
+ const pagination = findPagination(wrapper);
expect(pagination.isVisible()).toBe(true);
- localWrapper.setProps({
+ wrapper.setProps({
repo: {
pagination: {
total: 0,
@@ -182,13 +200,13 @@ describe('table registry', () => {
},
},
});
- expect(localWrapper.vm.shouldRenderPagination).toBe(false);
+ expect(wrapper.vm.shouldRenderPagination).toBe(false);
});
it('should have a change function that update the list when run', () => {
const fetchList = jest.fn().mockResolvedValue();
- localWrapper.setMethods({ fetchList });
- localWrapper.vm.onPageChange(1);
- expect(localWrapper.vm.fetchList).toHaveBeenCalledWith({ repo, page: 1 });
+ wrapper.setMethods({ fetchList });
+ wrapper.vm.onPageChange(1);
+ expect(wrapper.vm.fetchList).toHaveBeenCalledWith({ repo, page: 1 });
});
});
@@ -208,4 +226,41 @@ describe('table registry', () => {
expect(wrapper.vm.modalDescription).toContain('<b>2</b> tags');
});
});
+
+ describe('disabled delete', () => {
+ beforeEach(() => {
+ store = new Vuex.Store({
+ state: {
+ isDeleteDisabled: true,
+ },
+ getters,
+ });
+ wrapper = mountWithStore({
+ propsData: {
+ repo: repoPropsData,
+ canDeleteRepo: false,
+ },
+ });
+ });
+
+ it('should not render select all', () => {
+ const selectAll = findSelectAllCheckbox(wrapper);
+ expect(selectAll.exists()).toBe(false);
+ });
+
+ it('should not render any select checkbox', () => {
+ const selects = findSelectCheckboxes(wrapper);
+ expect(selects.length).toBe(0);
+ });
+
+ it('should not render delete registry button', () => {
+ const deleteBtn = findDeleteButton(wrapper);
+ expect(deleteBtn.exists()).toBe(false);
+ });
+
+ it('should not render delete row button', () => {
+ const deleteBtns = findDeleteButtonsRow(wrapper);
+ expect(deleteBtns.length).toBe(0);
+ });
+ });
});