Commit 887dd2b1 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'xanf-vtu-30-set-methods' into 'master'

Add nextTick to setMethods calls in Jest

Closes #191457

See merge request gitlab-org/gitlab!22318
parents 62c35c04 f2a3c80d
......@@ -59,6 +59,7 @@ describe('collapsible registry container', () => {
beforeEach(() => {
const fetchList = jest.fn();
wrapper.setMethods({ fetchList });
return wrapper.vm.$nextTick();
});
const expectIsClosed = () => {
......
......@@ -123,6 +123,8 @@ describe('table registry', () => {
it('should delete multiple items when multiple items are selected', done => {
const multiDeleteItems = jest.fn().mockResolvedValue();
wrapper.setMethods({ multiDeleteItems });
Vue.nextTick(() => {
const selectAll = findSelectAllCheckbox();
selectAll.trigger('click');
......@@ -132,8 +134,6 @@ describe('table registry', () => {
expect(deleteBtn.attributes('disabled')).toEqual(undefined);
wrapper.setData({ itemsToBeDeleted: [...wrapper.vm.selectedItems] });
wrapper.vm.handleMultipleDelete();
Vue.nextTick(() => {
expect(wrapper.vm.selectedItems).toEqual([]);
expect(wrapper.vm.itemsToBeDeleted).toEqual([]);
expect(wrapper.vm.multiDeleteItems).toHaveBeenCalledWith({
......@@ -179,12 +179,14 @@ describe('table registry', () => {
const deleteSingleItem = jest.fn();
const deleteItem = jest.fn().mockResolvedValue();
wrapper.setMethods({ deleteSingleItem, deleteItem });
return wrapper.vm.$nextTick().then(() => {
deleteBtns.at(0).trigger('click');
expect(wrapper.vm.deleteSingleItem).toHaveBeenCalledWith(0);
wrapper.vm.handleSingleDelete(1);
expect(wrapper.vm.deleteItem).toHaveBeenCalledWith(1);
});
});
});
describe('modal event handlers', () => {
beforeEach(() => {
......
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