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

65 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import collapsibleComponent from '~/registry/components/collapsible_container.vue';
import store from '~/registry/stores';
import { repoPropsData } from '../mock_data';
describe('collapsible registry container', () => {
let vm;
let Component;
beforeEach(() => {
Component = Vue.extend(collapsibleComponent);
vm = new Component({
store,
propsData: {
repo: repoPropsData,
},
}).$mount();
});
afterEach(() => {
vm.$destroy();
});
describe('toggle', () => {
it('should be closed by default', () => {
expect(vm.$el.querySelector('.container-image-tags')).toBe(null);
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.container-image-head i').className).toEqual(
'fa fa-chevron-right',
);
2018-03-17 18:26:18 +05:30
});
2018-12-13 13:39:08 +05:30
it('should be open when user clicks on closed repo', done => {
2018-03-17 18:26:18 +05:30
vm.$el.querySelector('.js-toggle-repo').click();
Vue.nextTick(() => {
expect(vm.$el.querySelector('.container-image-tags')).toBeDefined();
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.container-image-head i').className).toEqual(
'fa fa-chevron-up',
);
2018-03-17 18:26:18 +05:30
done();
});
});
2018-12-13 13:39:08 +05:30
it('should be closed when the user clicks on an opened repo', done => {
2018-03-17 18:26:18 +05:30
vm.$el.querySelector('.js-toggle-repo').click();
Vue.nextTick(() => {
vm.$el.querySelector('.js-toggle-repo').click();
Vue.nextTick(() => {
expect(vm.$el.querySelector('.container-image-tags')).toBe(null);
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.container-image-head i').className).toEqual(
'fa fa-chevron-right',
);
2018-03-17 18:26:18 +05:30
done();
});
});
});
});
describe('delete repo', () => {
it('should be possible to delete a repo', () => {
expect(vm.$el.querySelector('.js-remove-repo')).toBeDefined();
});
});
});