diff options
author | Paul Gascou-Vaillancourt <paul.gascvail@gmail.com> | 2019-06-28 11:06:33 -0400 |
---|---|---|
committer | Lukas Eipert <leipert@gitlab.com> | 2019-06-28 18:47:08 +0200 |
commit | 2643d3b38534533c16f36d37fe56a6be56445479 (patch) | |
tree | 51e82807c50864853b718a142b29ee8854157bd5 | |
parent | 7abbbce38cdb652880b3f0166363ff39462983bd (diff) | |
download | gitlab-ce-2643d3b38534533c16f36d37fe56a6be56445479.tar.gz |
Fix modal related tests
-rw-r--r-- | spec/javascripts/registry/components/collapsible_container_spec.js | 18 | ||||
-rw-r--r-- | spec/javascripts/registry/components/table_registry_spec.js | 19 |
2 files changed, 12 insertions, 25 deletions
diff --git a/spec/javascripts/registry/components/collapsible_container_spec.js b/spec/javascripts/registry/components/collapsible_container_spec.js index 9ed4b04324a..55017b3e26b 100644 --- a/spec/javascripts/registry/components/collapsible_container_spec.js +++ b/spec/javascripts/registry/components/collapsible_container_spec.js @@ -72,21 +72,15 @@ describe('collapsible registry container', () => { expect(findDeleteBtn()).not.toBeNull(); }); - describe('clicked on delete', () => { - beforeEach(done => { - findDeleteBtn().click(); - Vue.nextTick(done); - }); - - it('should open confirmation modal', () => { - expect(vm.$el.querySelector('#confirm-repo-deletion-modal')).not.toBeNull(); - }); + it('should call deleteItem when confirming deletion', done => { + findDeleteBtn().click(); + spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve()); - it('should call deleteItem when confirming deletion', () => { - spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve()); - vm.$el.querySelector('#confirm-repo-deletion-modal .btn-danger').click(); + Vue.nextTick(() => { + document.querySelector('#confirm-repo-deletion-modal .btn-danger').click(); expect(vm.deleteItem).toHaveBeenCalledWith(vm.repo); + done(); }); }); }); diff --git a/spec/javascripts/registry/components/table_registry_spec.js b/spec/javascripts/registry/components/table_registry_spec.js index d366c67a1b9..6a0b16f592e 100644 --- a/spec/javascripts/registry/components/table_registry_spec.js +++ b/spec/javascripts/registry/components/table_registry_spec.js @@ -46,23 +46,16 @@ describe('table registry', () => { expect(findDeleteBtn()).toBeDefined(); }); - describe('clicked on delete', () => { - beforeEach(done => { - findDeleteBtn().click(); - Vue.nextTick(done); - }); - - it('should open confirmation modal and set itemToBeDeleted properly', () => { - expect(vm.itemToBeDeleted).toEqual(firstImage); - expect(vm.$el.querySelector('#confirm-image-deletion-modal')).not.toBeNull(); - }); + it('should call deleteItem and reset itemToBeDeleted when confirming deletion', done => { + findDeleteBtn().click(); + spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve()); - it('should call deleteItem and reset itemToBeDeleted when confirming deletion', () => { - spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve()); - vm.$el.querySelector('#confirm-image-deletion-modal .btn-danger').click(); + Vue.nextTick(() => { + document.querySelector('#confirm-image-deletion-modal .btn-danger').click(); expect(vm.deleteItem).toHaveBeenCalledWith(firstImage); expect(vm.itemToBeDeleted).toBeNull(); + done(); }); }); }); |