debian-mirror-gitlab/spec/javascripts/registry/components/table_registry_spec.js

69 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import tableRegistry from '~/registry/components/table_registry.vue';
import store from '~/registry/stores';
import { repoPropsData } from '../mock_data';
2019-09-30 21:07:59 +05:30
const [firstImage] = repoPropsData.list;
2018-03-17 18:26:18 +05:30
describe('table registry', () => {
let vm;
let Component;
2019-09-30 21:07:59 +05:30
const findDeleteBtn = () => vm.$el.querySelector('.js-delete-registry');
2018-03-17 18:26:18 +05:30
beforeEach(() => {
Component = Vue.extend(tableRegistry);
vm = new Component({
store,
propsData: {
repo: repoPropsData,
},
}).$mount();
});
afterEach(() => {
vm.$destroy();
});
it('should render a table with the registry list', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelectorAll('table tbody tr').length).toEqual(repoPropsData.list.length);
2018-03-17 18:26:18 +05:30
});
it('should render registry tag', () => {
2018-12-13 13:39:08 +05:30
const textRendered = vm.$el
.querySelector('.table tbody tr')
.textContent.trim()
.replace(/\s\s+/g, ' ');
2018-03-17 18:26:18 +05:30
expect(textRendered).toContain(repoPropsData.list[0].tag);
expect(textRendered).toContain(repoPropsData.list[0].shortRevision);
expect(textRendered).toContain(repoPropsData.list[0].layers);
expect(textRendered).toContain(repoPropsData.list[0].size);
});
2019-09-30 21:07:59 +05:30
describe('delete registry', () => {
it('should be possible to delete a registry', () => {
expect(findDeleteBtn()).toBeDefined();
});
it('should call deleteItem and reset itemToBeDeleted when confirming deletion', done => {
findDeleteBtn().click();
spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve());
Vue.nextTick(() => {
document.querySelector(`#${vm.modalId} .btn-danger`).click();
expect(vm.deleteItem).toHaveBeenCalledWith(firstImage);
expect(vm.itemToBeDeleted).toBeNull();
done();
});
});
2018-03-17 18:26:18 +05:30
});
describe('pagination', () => {
it('should be possible to change the page', () => {
expect(vm.$el.querySelector('.gl-pagination')).toBeDefined();
});
});
});