Commit 58f1442c authored by Paul Gascou-Vaillancourt's avatar Paul Gascou-Vaillancourt Committed by Lukas Eipert

Fix modal related tests

parent 20f77f33
...@@ -72,21 +72,15 @@ describe('collapsible registry container', () => { ...@@ -72,21 +72,15 @@ describe('collapsible registry container', () => {
expect(findDeleteBtn()).not.toBeNull(); expect(findDeleteBtn()).not.toBeNull();
}); });
describe('clicked on delete', () => { it('should call deleteItem when confirming deletion', done => {
beforeEach(done => { findDeleteBtn().click();
findDeleteBtn().click(); spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve());
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', () => { Vue.nextTick(() => {
spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve()); document.querySelector('#confirm-repo-deletion-modal .btn-danger').click();
vm.$el.querySelector('#confirm-repo-deletion-modal .btn-danger').click();
expect(vm.deleteItem).toHaveBeenCalledWith(vm.repo); expect(vm.deleteItem).toHaveBeenCalledWith(vm.repo);
done();
}); });
}); });
}); });
......
...@@ -46,23 +46,16 @@ describe('table registry', () => { ...@@ -46,23 +46,16 @@ describe('table registry', () => {
expect(findDeleteBtn()).toBeDefined(); expect(findDeleteBtn()).toBeDefined();
}); });
describe('clicked on delete', () => { it('should call deleteItem and reset itemToBeDeleted when confirming deletion', done => {
beforeEach(done => { findDeleteBtn().click();
findDeleteBtn().click(); spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve());
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', () => { Vue.nextTick(() => {
spyOn(vm, 'deleteItem').and.returnValue(Promise.resolve()); document.querySelector('#confirm-image-deletion-modal .btn-danger').click();
vm.$el.querySelector('#confirm-image-deletion-modal .btn-danger').click();
expect(vm.deleteItem).toHaveBeenCalledWith(firstImage); expect(vm.deleteItem).toHaveBeenCalledWith(firstImage);
expect(vm.itemToBeDeleted).toBeNull(); expect(vm.itemToBeDeleted).toBeNull();
done();
}); });
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment