Commit 2c45f6ed authored by Mark Florian's avatar Mark Florian

Merge branch '204850-refactor-container-registry-unit-tests-to-not-use-setdata' into 'master'

Refactor container registry tests to avoid setData

Closes #204850

See merge request gitlab-org/gitlab!34286
parents 5c215a8d c716d1d9
......@@ -88,18 +88,17 @@ describe('tags_table', () => {
mountComponent();
});
it('if selected adds item to selectedItems', () => {
it('selecting and deselecting the checkbox works as intended', () => {
findFirstRowItem('rowCheckbox').vm.$emit('change');
return wrapper.vm.$nextTick().then(() => {
return wrapper.vm
.$nextTick()
.then(() => {
expect(wrapper.vm.selectedItems).toEqual([tags[0].name]);
expect(findFirstRowItem('rowCheckbox').attributes('checked')).toBeTruthy();
});
});
it('if deselect remove name from selectedItems', () => {
wrapper.setData({ selectedItems: [tags[0].name] });
findFirstRowItem('rowCheckbox').vm.$emit('change');
return wrapper.vm.$nextTick().then(() => {
return wrapper.vm.$nextTick();
})
.then(() => {
expect(wrapper.vm.selectedItems.length).toBe(0);
expect(findFirstRowItem('rowCheckbox').attributes('checked')).toBe(undefined);
});
......
......@@ -55,7 +55,7 @@ describe('Image List', () => {
});
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]]);
});
});
......
......@@ -174,7 +174,7 @@ describe('Details Page', () => {
it('fetch the data from the API when the v-model changes', () => {
dispatchSpy.mockResolvedValue();
wrapper.setData({ currentPage: 2 });
findPagination().vm.$emit(GlPagination.model.event, 2);
expect(store.dispatch).toHaveBeenCalledWith('requestTagsList', {
params: wrapper.vm.$route.params.id,
pagination: { page: 2 },
......
......@@ -302,7 +302,7 @@ describe('List Page', () => {
});
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(() => {
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