BigW Consortium Gitlab

collapsible_container_spec.js 1.75 KB
Newer Older
1 2
import Vue from 'vue';
import collapsibleComponent from '~/registry/components/collapsible_container.vue';
3 4
import store from '~/registry/stores';
import { repoPropsData } from '../mock_data';
5 6 7 8 9 10 11

describe('collapsible registry container', () => {
  let vm;
  let Component;

  beforeEach(() => {
    Component = Vue.extend(collapsibleComponent);
12 13 14 15
    vm = new Component({
      store,
      propsData: {
        repo: repoPropsData,
Filipa Lacerda committed
16
      },
17
    }).$mount();
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
  });

  afterEach(() => {
    vm.$destroy();
  });

  describe('toggle', () => {
    it('should be closed by default', () => {
      expect(vm.$el.querySelector('.container-image-tags')).toBe(null);
      expect(vm.$el.querySelector('.container-image-head i').className).toEqual('fa fa-chevron-right');
    });

    it('should be open when user clicks on closed repo', (done) => {
      vm.$el.querySelector('.js-toggle-repo').click();
      Vue.nextTick(() => {
        expect(vm.$el.querySelector('.container-image-tags')).toBeDefined();
        expect(vm.$el.querySelector('.container-image-head i').className).toEqual('fa fa-chevron-up');
        done();
      });
    });

    it('should be closed when the user clicks on an opened repo', (done) => {
      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);
          expect(vm.$el.querySelector('.container-image-head i').className).toEqual('fa fa-chevron-right');
          done();
        });
      });
    });
  });

  describe('delete repo', () => {
    it('should be possible to delete a repo', () => {
      expect(vm.$el.querySelector('.js-remove-repo')).toBeDefined();
    });
  });
});