diff options
Diffstat (limited to 'spec/javascripts/registry/components/collapsible_container_spec.js')
-rw-r--r-- | spec/javascripts/registry/components/collapsible_container_spec.js | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/spec/javascripts/registry/components/collapsible_container_spec.js b/spec/javascripts/registry/components/collapsible_container_spec.js index 069139bc564..a3f7ff76dc7 100644 --- a/spec/javascripts/registry/components/collapsible_container_spec.js +++ b/spec/javascripts/registry/components/collapsible_container_spec.js @@ -3,7 +3,9 @@ import axios from '~/lib/utils/axios_utils'; import Vue from 'vue'; import collapsibleComponent from '~/registry/components/collapsible_container.vue'; import store from '~/registry/stores'; -import { repoPropsData, registryServerResponse } from '../mock_data'; +import * as types from '~/registry/stores/mutation_types'; + +import { repoPropsData, registryServerResponse, reposServerResponse } from '../mock_data'; describe('collapsible registry container', () => { let vm; @@ -13,9 +15,9 @@ describe('collapsible registry container', () => { beforeEach(() => { mock = new MockAdapter(axios); - mock - .onGet(repoPropsData.tagsPath) - .replyOnce(200, registryServerResponse, {}); + mock.onGet(repoPropsData.tagsPath).replyOnce(200, registryServerResponse, {}); + + store.commit(types.SET_REPOS_LIST, reposServerResponse); vm = new Component({ store, @@ -33,25 +35,16 @@ describe('collapsible registry container', () => { 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', - ); + expect(vm.iconName).toEqual('angle-right'); }); - fit('should be open when user clicks on closed repo', done => { - - console.log(vm.repo, vm.$el) - + it('should be open when user clicks on closed repo', done => { vm.$el.querySelector('.js-toggle-repo').click(); - + Vue.nextTick(() => { - - console.log('nextTick', vm.repo, vm.$el) - expect(vm.$el.querySelector('.container-image-tags')).not.toBeNull(); - expect(vm.$el.querySelector('.container-image-head i').className).toEqual( - 'fa fa-chevron-up', - ); + expect(vm.iconName).toEqual('angle-up'); + done(); }); }); @@ -61,12 +54,12 @@ describe('collapsible registry container', () => { 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(); + setTimeout(() => { + Vue.nextTick(() => { + expect(vm.$el.querySelector('.container-image-tags')).toBe(null); + expect(vm.iconName).toEqual('angle-right'); + done(); + }); }); }); }); |