Commit c716d1d9 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Mark Florian

Remove setData from the codebase

- swap setData for the equivalent dom action
- tags_table
- image_list
- details_spec
- list_spec
parent e5d7d61b
...@@ -88,21 +88,20 @@ describe('tags_table', () => { ...@@ -88,21 +88,20 @@ describe('tags_table', () => {
mountComponent(); mountComponent();
}); });
it('if selected adds item to selectedItems', () => { it('selecting and deselecting the checkbox works as intended', () => {
findFirstRowItem('rowCheckbox').vm.$emit('change'); findFirstRowItem('rowCheckbox').vm.$emit('change');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm
expect(wrapper.vm.selectedItems).toEqual([tags[0].name]); .$nextTick()
expect(findFirstRowItem('rowCheckbox').attributes('checked')).toBeTruthy(); .then(() => {
}); expect(wrapper.vm.selectedItems).toEqual([tags[0].name]);
}); expect(findFirstRowItem('rowCheckbox').attributes('checked')).toBeTruthy();
findFirstRowItem('rowCheckbox').vm.$emit('change');
it('if deselect remove name from selectedItems', () => { return wrapper.vm.$nextTick();
wrapper.setData({ selectedItems: [tags[0].name] }); })
findFirstRowItem('rowCheckbox').vm.$emit('change'); .then(() => {
return wrapper.vm.$nextTick().then(() => { expect(wrapper.vm.selectedItems.length).toBe(0);
expect(wrapper.vm.selectedItems.length).toBe(0); expect(findFirstRowItem('rowCheckbox').attributes('checked')).toBe(undefined);
expect(findFirstRowItem('rowCheckbox').attributes('checked')).toBe(undefined); });
});
}); });
}); });
......
...@@ -55,7 +55,7 @@ describe('Image List', () => { ...@@ -55,7 +55,7 @@ describe('Image List', () => {
}); });
it('emits a pageChange event when the page change', () => { it('emits a pageChange event when the page change', () => {
wrapper.setData({ currentPage: 2 }); findPagination().vm.$emit(GlPagination.model.event, 2);
expect(wrapper.emitted('pageChange')).toEqual([[2]]); expect(wrapper.emitted('pageChange')).toEqual([[2]]);
}); });
}); });
......
...@@ -174,7 +174,7 @@ describe('Details Page', () => { ...@@ -174,7 +174,7 @@ describe('Details Page', () => {
it('fetch the data from the API when the v-model changes', () => { it('fetch the data from the API when the v-model changes', () => {
dispatchSpy.mockResolvedValue(); dispatchSpy.mockResolvedValue();
wrapper.setData({ currentPage: 2 }); findPagination().vm.$emit(GlPagination.model.event, 2);
expect(store.dispatch).toHaveBeenCalledWith('requestTagsList', { expect(store.dispatch).toHaveBeenCalledWith('requestTagsList', {
params: wrapper.vm.$route.params.id, params: wrapper.vm.$route.params.id,
pagination: { page: 2 }, pagination: { page: 2 },
......
...@@ -302,7 +302,7 @@ describe('List Page', () => { ...@@ -302,7 +302,7 @@ describe('List Page', () => {
}); });
it('contains a description with the path of the item to delete', () => { it('contains a description with the path of the item to delete', () => {
wrapper.setData({ itemToDelete: { path: 'foo' } }); findImageList().vm.$emit('delete', { path: 'foo' });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(findDeleteModal().html()).toContain('foo'); expect(findDeleteModal().html()).toContain('foo');
}); });
......
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