Commit a3ffe24d authored by Vitaly Slobodin's avatar Vitaly Slobodin

Replace Vue.$emit with single arg in groups

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