Commit 67eea047 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'vs/replace-vue-emit-with-single-arg-in-groups' into 'master'

Replace Vue.$emit with single arg in groups

See merge request gitlab-org/gitlab!68930
parents c54accf0 a3ffe24d
......@@ -136,7 +136,7 @@ export default {
this.updateGroups(res, Boolean(filterGroupsBy));
});
},
fetchPage(page, filterGroupsBy, sortBy, archived) {
fetchPage({ page, filterGroupsBy, sortBy, archived }) {
this.isLoading = true;
return this.fetchGroups({
......
......@@ -32,10 +32,10 @@ export default {
},
methods: {
change(page) {
const filterGroupsParam = getParameterByName('filter');
const sortParam = getParameterByName('sort');
const archivedParam = getParameterByName('archived');
eventHub.$emit(`${this.action}fetchPage`, page, filterGroupsParam, sortParam, archivedParam);
const filterGroupsBy = getParameterByName('filter');
const sortBy = getParameterByName('sort');
const archived = getParameterByName('archived');
eventHub.$emit(`${this.action}fetchPage`, { page, filterGroupsBy, sortBy, archived });
},
},
};
......
......@@ -182,7 +182,12 @@ describe('AppComponent', () => {
jest.spyOn(window.history, 'replaceState').mockImplementation(() => {});
jest.spyOn(window, 'scrollTo').mockImplementation(() => {});
const fetchPagePromise = vm.fetchPage(2, null, null, true);
const fetchPagePromise = vm.fetchPage({
page: 2,
filterGroupsBy: null,
sortBy: null,
archived: true,
});
expect(vm.isLoading).toBe(true);
expect(vm.fetchGroups).toHaveBeenCalledWith({
......
......@@ -41,13 +41,12 @@ describe('GroupsComponent', () => {
vm.change(2);
expect(eventHub.$emit).toHaveBeenCalledWith(
'fetchPage',
2,
expect.any(Object),
expect.any(Object),
expect.any(Object),
);
expect(eventHub.$emit).toHaveBeenCalledWith('fetchPage', {
page: 2,
archived: null,
filterGroupsBy: null,
sortBy: null,
});
});
});
});
......
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