Commit 797612bc authored by Vitaly Slobodin's avatar Vitaly Slobodin

Replace $emit call with a single arg in sidebar

See https://gitlab.com/groups/gitlab-org/-/epics/3334
parent c1e45452
...@@ -103,7 +103,7 @@ export default { ...@@ -103,7 +103,7 @@ export default {
dueDateTimeFromMilestones: this.dueDateTimeFromMilestones, dueDateTimeFromMilestones: this.dueDateTimeFromMilestones,
}); });
}, },
changeStartDateType(dateTypeIsFixed, typeChangeOnEdit) { changeStartDateType({ dateTypeIsFixed, typeChangeOnEdit }) {
this.toggleStartDateType({ dateTypeIsFixed }); this.toggleStartDateType({ dateTypeIsFixed });
if (!typeChangeOnEdit) { if (!typeChangeOnEdit) {
this.saveDate({ this.saveDate({
...@@ -120,7 +120,7 @@ export default { ...@@ -120,7 +120,7 @@ export default {
dateTypeIsFixed: true, dateTypeIsFixed: true,
}); });
}, },
changeDueDateType(dateTypeIsFixed, typeChangeOnEdit) { changeDueDateType({ dateTypeIsFixed, typeChangeOnEdit }) {
this.toggleDueDateType({ dateTypeIsFixed }); this.toggleDueDateType({ dateTypeIsFixed });
if (!typeChangeOnEdit) { if (!typeChangeOnEdit) {
this.saveDate({ this.saveDate({
......
...@@ -133,7 +133,7 @@ export default { ...@@ -133,7 +133,7 @@ export default {
methods: { methods: {
stopEditing() { stopEditing() {
this.editing = false; this.editing = false;
this.$emit('toggleDateType', true, true); this.$emit('toggleDateType', { dateTypeIsFixed: true, typeChangeOnEdit: true });
}, },
startEditing(e) { startEditing(e) {
this.editing = true; this.editing = true;
...@@ -144,7 +144,7 @@ export default { ...@@ -144,7 +144,7 @@ export default {
this.$emit('saveDate', date); this.$emit('saveDate', date);
}, },
toggleDateType(dateTypeFixed) { toggleDateType(dateTypeFixed) {
this.$emit('toggleDateType', dateTypeFixed); this.$emit('toggleDateType', { dateTypeIsFixed: dateTypeFixed });
}, },
toggleSidebar() { toggleSidebar() {
this.$emit('toggleCollapse'); this.$emit('toggleCollapse');
......
...@@ -68,7 +68,7 @@ describe('EpicSidebarComponent', () => { ...@@ -68,7 +68,7 @@ describe('EpicSidebarComponent', () => {
it('calls `toggleStartDateType` on component with `dateTypeIsFixed` param', () => { it('calls `toggleStartDateType` on component with `dateTypeIsFixed` param', () => {
jest.spyOn(wrapper.vm, 'toggleStartDateType'); jest.spyOn(wrapper.vm, 'toggleStartDateType');
wrapper.vm.changeStartDateType(true, true); wrapper.vm.changeStartDateType({ dateTypeIsFixed: true, typeChangeOnEdit: true });
expect(wrapper.vm.toggleStartDateType).toHaveBeenCalledWith( expect(wrapper.vm.toggleStartDateType).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
...@@ -80,7 +80,7 @@ describe('EpicSidebarComponent', () => { ...@@ -80,7 +80,7 @@ describe('EpicSidebarComponent', () => {
it('calls `saveDate` on component when `typeChangeOnEdit` param false', () => { it('calls `saveDate` on component when `typeChangeOnEdit` param false', () => {
jest.spyOn(wrapper.vm, 'saveDate'); jest.spyOn(wrapper.vm, 'saveDate');
wrapper.vm.changeStartDateType(true, false); wrapper.vm.changeStartDateType({ dateTypeIsFixed: true, typeChangeOnEdit: false });
expect(wrapper.vm.saveDate).toHaveBeenCalledWith( expect(wrapper.vm.saveDate).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
...@@ -112,7 +112,7 @@ describe('EpicSidebarComponent', () => { ...@@ -112,7 +112,7 @@ describe('EpicSidebarComponent', () => {
it('calls `toggleDueDateType` on component with `dateTypeIsFixed` param', () => { it('calls `toggleDueDateType` on component with `dateTypeIsFixed` param', () => {
jest.spyOn(wrapper.vm, 'toggleDueDateType'); jest.spyOn(wrapper.vm, 'toggleDueDateType');
wrapper.vm.changeDueDateType(true, true); wrapper.vm.changeDueDateType({ dateTypeIsFixed: true, typeChangeOnEdit: true });
expect(wrapper.vm.toggleDueDateType).toHaveBeenCalledWith( expect(wrapper.vm.toggleDueDateType).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
...@@ -124,7 +124,7 @@ describe('EpicSidebarComponent', () => { ...@@ -124,7 +124,7 @@ describe('EpicSidebarComponent', () => {
it('calls `saveDate` on component when `typeChangeOnEdit` param false', () => { it('calls `saveDate` on component when `typeChangeOnEdit` param false', () => {
jest.spyOn(wrapper.vm, 'saveDate'); jest.spyOn(wrapper.vm, 'saveDate');
wrapper.vm.changeDueDateType(true, false); wrapper.vm.changeDueDateType({ dateTypeIsFixed: true, typeChangeOnEdit: false });
expect(wrapper.vm.saveDate).toHaveBeenCalledWith( expect(wrapper.vm.saveDate).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
......
...@@ -146,7 +146,9 @@ describe('SidebarDatePicker', () => { ...@@ -146,7 +146,9 @@ describe('SidebarDatePicker', () => {
.$nextTick() .$nextTick()
.then(() => { .then(() => {
wrapper.find(DatePicker).vm.$emit('hidePicker'); wrapper.find(DatePicker).vm.$emit('hidePicker');
expect(wrapper.emitted().toggleDateType[0]).toStrictEqual([true, true]); expect(wrapper.emitted().toggleDateType[0]).toStrictEqual([
{ dateTypeIsFixed: true, typeChangeOnEdit: true },
]);
}) })
.then(() => wrapper.vm.$nextTick()) .then(() => wrapper.vm.$nextTick())
.then(() => { .then(() => {
...@@ -184,7 +186,7 @@ describe('SidebarDatePicker', () => { ...@@ -184,7 +186,7 @@ describe('SidebarDatePicker', () => {
wrapper.find('input').trigger('click'); wrapper.find('input').trigger('click');
return wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.emitted().toggleDateType).toStrictEqual([[true]]); expect(wrapper.emitted().toggleDateType).toStrictEqual([[{ dateTypeIsFixed: true }]]);
}); });
}); });
......
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