Commit 766263d7 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'xanf-remove-emittedByOrder' into 'master'

Remove emittedByOrder and isEmpty due to future deprecation

See merge request gitlab-org/gitlab!40523
parents e32f449b b955217b
...@@ -84,10 +84,10 @@ describe('PathNavigation', () => { ...@@ -84,10 +84,10 @@ describe('PathNavigation', () => {
clickItemAt(1); clickItemAt(1);
clickItemAt(2); clickItemAt(2);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([
{ name: 'selected', args: [transformedStagePathData[0]] }, [transformedStagePathData[0]],
{ name: 'selected', args: [transformedStagePathData[1]] }, [transformedStagePathData[1]],
{ name: 'selected', args: [transformedStagePathData[2]] }, [transformedStagePathData[2]],
]); ]);
}); });
}); });
......
...@@ -49,12 +49,7 @@ describe('StageDropdownFilter component', () => { ...@@ -49,12 +49,7 @@ describe('StageDropdownFilter component', () => {
it('should remove from selection', () => { it('should remove from selection', () => {
selectDropdownItemAtIndex(0); selectDropdownItemAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([[[stages[1], stages[2]]]]);
{
name: 'selected',
args: [[stages[1], stages[2]]],
},
]);
}); });
}); });
...@@ -66,15 +61,9 @@ describe('StageDropdownFilter component', () => { ...@@ -66,15 +61,9 @@ describe('StageDropdownFilter component', () => {
it('should add to selection', () => { it('should add to selection', () => {
selectDropdownItemAtIndex(0); selectDropdownItemAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([
{ [[stages[1], stages[2]]],
name: 'selected', [[stages[1], stages[2], stages[0]]],
args: [[stages[1], stages[2]]],
},
{
name: 'selected',
args: [[stages[1], stages[2], stages[0]]],
},
]); ]);
}); });
}); });
......
...@@ -60,12 +60,7 @@ describe('Daterange component', () => { ...@@ -60,12 +60,7 @@ describe('Daterange component', () => {
input.trigger('change'); input.trigger('change');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().change).toEqual([[{ startDate: minDate, endDate }]]);
{
name: 'change',
args: [{ startDate: minDate, endDate }],
},
]);
}); });
}); });
}); });
...@@ -101,12 +96,7 @@ describe('Daterange component', () => { ...@@ -101,12 +96,7 @@ describe('Daterange component', () => {
const endDate = new Date('2019-10-05'); const endDate = new Date('2019-10-05');
wrapper.vm.dateRange = { startDate, endDate }; wrapper.vm.dateRange = { startDate, endDate };
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().change).toEqual([[{ startDate, endDate }]]);
{
name: 'change',
args: [{ startDate, endDate }],
},
]);
}); });
}); });
......
...@@ -109,23 +109,13 @@ describe('GroupsDropdownFilter component', () => { ...@@ -109,23 +109,13 @@ describe('GroupsDropdownFilter component', () => {
it('should emit the "selected" event with the selected group', () => { it('should emit the "selected" event with the selected group', () => {
selectDropdownAtIndex(0); selectDropdownAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([[groups[0]]]);
{
name: 'selected',
args: [groups[0]],
},
]);
}); });
it('should change selection when new group is clicked', () => { it('should change selection when new group is clicked', () => {
selectDropdownAtIndex(1); selectDropdownAtIndex(1);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([[groups[1]]]);
{
name: 'selected',
args: [groups[1]],
},
]);
}); });
it('renders an avatar in the dropdown button when the group has an avatar_url', () => { it('renders an avatar in the dropdown button when the group has an avatar_url', () => {
......
...@@ -131,39 +131,20 @@ describe('ProjectsDropdownFilter component', () => { ...@@ -131,39 +131,20 @@ describe('ProjectsDropdownFilter component', () => {
it('should emit the "selected" event with the selected project', () => { it('should emit the "selected" event with the selected project', () => {
selectDropdownItemAtIndex(0); selectDropdownItemAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([[[projects[0]]]]);
{
name: 'selected',
args: [[projects[0]]],
},
]);
}); });
it('should change selection when new project is clicked', () => { it('should change selection when new project is clicked', () => {
selectDropdownItemAtIndex(1); selectDropdownItemAtIndex(1);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([[[projects[1]]]]);
{
name: 'selected',
args: [[projects[1]]],
},
]);
}); });
it('selection should be emptied when a project is deselected', () => { it('selection should be emptied when a project is deselected', () => {
selectDropdownItemAtIndex(0); // Select the item selectDropdownItemAtIndex(0); // Select the item
selectDropdownItemAtIndex(0); // deselect it selectDropdownItemAtIndex(0); // deselect it
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([[[projects[0]]], [[]]]);
{
name: 'selected',
args: [[projects[0]]],
},
{
name: 'selected',
args: [[]],
},
]);
}); });
it('renders an avatar in the dropdown button when the project has an avatar_url', () => { it('renders an avatar in the dropdown button when the project has an avatar_url', () => {
...@@ -212,32 +193,14 @@ describe('ProjectsDropdownFilter component', () => { ...@@ -212,32 +193,14 @@ describe('ProjectsDropdownFilter component', () => {
selectDropdownItemAtIndex(0); selectDropdownItemAtIndex(0);
selectDropdownItemAtIndex(1); selectDropdownItemAtIndex(1);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([[[projects[0]]], [[projects[0], projects[1]]]]);
{
name: 'selected',
args: [[projects[0]]],
},
{
name: 'selected',
args: [[projects[0], projects[1]]],
},
]);
}); });
it('should remove from selection when clicked again', () => { it('should remove from selection when clicked again', () => {
selectDropdownItemAtIndex(0); selectDropdownItemAtIndex(0);
selectDropdownItemAtIndex(0); selectDropdownItemAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted().selected).toEqual([[[projects[0]]], [[]]]);
{
name: 'selected',
args: [[projects[0]]],
},
{
name: 'selected',
args: [[]],
},
]);
}); });
it('renders the correct placeholder text when multiple projects are selected', () => { it('renders the correct placeholder text when multiple projects are selected', () => {
......
...@@ -51,7 +51,7 @@ describe('Approvals ApproversListItem', () => { ...@@ -51,7 +51,7 @@ describe('Approvals ApproversListItem', () => {
button.vm.$emit('click'); button.vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toEqual([{ name: 'remove', args: [TEST_USER] }]); expect(wrapper.emitted().remove).toEqual([[TEST_USER]]);
}); });
}); });
}); });
......
...@@ -65,7 +65,7 @@ describe('ApproversList', () => { ...@@ -65,7 +65,7 @@ describe('ApproversList', () => {
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
const expected = TEST_APPROVERS.filter((x, i) => i !== idx); const expected = TEST_APPROVERS.filter((x, i) => i !== idx);
expect(wrapper.emittedByOrder()).toEqual([{ name: 'input', args: [expected] }]); expect(wrapper.emitted().input).toEqual([[expected]]);
}); });
}); });
}); });
......
...@@ -173,10 +173,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -173,10 +173,7 @@ describe('Approvals ApproversSelect', () => {
{ ...TEST_USERS[0], type: TYPE_USER }, { ...TEST_USERS[0], type: TYPE_USER },
{ ...TEST_GROUPS[0], type: TYPE_GROUP }, { ...TEST_GROUPS[0], type: TYPE_GROUP },
]; ];
const expected = expectedFinal.map((x, idx) => ({ const expected = expectedFinal.map((x, idx) => [expectedFinal.slice(0, idx + 1)]);
name: 'input',
args: [expectedFinal.slice(0, idx + 1)],
}));
waitForEvent($input, 'select2-loaded') waitForEvent($input, 'select2-loaded')
.then(() => { .then(() => {
...@@ -191,7 +188,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -191,7 +188,7 @@ describe('Approvals ApproversSelect', () => {
waitForEvent($input, 'change') waitForEvent($input, 'change')
.then(jest.runOnlyPendingTimers) .then(jest.runOnlyPendingTimers)
.then(() => { .then(() => {
expect(wrapper.emittedByOrder()).toEqual(expected); expect(wrapper.emitted().input).toEqual(expected);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
...@@ -121,12 +121,7 @@ describe('Branches Select', () => { ...@@ -121,12 +121,7 @@ describe('Branches Select', () => {
const selectedIndex = 1; const selectedIndex = 1;
const selectedId = TEST_BRANCHES_SELECTIONS[selectedIndex].id; const selectedId = TEST_BRANCHES_SELECTIONS[selectedIndex].id;
const expected = [ const expected = [[selectedId]];
{
name: 'input',
args: [selectedId],
},
];
waitForEvent($input, 'select2-loaded') waitForEvent($input, 'select2-loaded')
.then(() => { .then(() => {
...@@ -138,7 +133,7 @@ describe('Branches Select', () => { ...@@ -138,7 +133,7 @@ describe('Branches Select', () => {
waitForEvent($input, 'change') waitForEvent($input, 'change')
.then(() => { .then(() => {
expect(wrapper.emittedByOrder()).toEqual(expected); expect(wrapper.emitted().input).toEqual(expected);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
...@@ -52,12 +52,7 @@ describe('project header component', () => { ...@@ -52,12 +52,7 @@ describe('project header component', () => {
wrapper.find('.js-remove-button').vm.$emit('click'); wrapper.find('.js-remove-button').vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toContainEqual( expect(wrapper.emitted().remove).toStrictEqual([[mockOneProject.remove_path]]);
expect.objectContaining({
name: 'remove',
args: [mockOneProject.remove_path],
}),
);
}); });
}); });
}); });
......
...@@ -128,10 +128,8 @@ describe('Selection Summary component', () => { ...@@ -128,10 +128,8 @@ describe('Selection Summary component', () => {
it('should emit an event to refetch the vulnerabilities when the request is successful', () => { it('should emit an event to refetch the vulnerabilities when the request is successful', () => {
dismissButton().trigger('submit'); dismissButton().trigger('submit');
return waitForPromises().then(() => { return waitForPromises().then(() => {
expect(wrapper.emittedByOrder()).toEqual([ expect(wrapper.emitted('deselect-all-vulnerabilities')).toEqual([[]]);
{ name: 'deselect-all-vulnerabilities', args: [] }, expect(wrapper.emitted('refetch-vulnerabilities')).toEqual([[]]);
{ name: 'refetch-vulnerabilities', args: [] },
]);
}); });
}); });
...@@ -139,7 +137,7 @@ describe('Selection Summary component', () => { ...@@ -139,7 +137,7 @@ describe('Selection Summary component', () => {
mutateMock.mockRejectedValue(); mutateMock.mockRejectedValue();
dismissButton().trigger('submit'); dismissButton().trigger('submit');
return waitForPromises().then(() => { return waitForPromises().then(() => {
expect(wrapper.emittedByOrder()).toEqual([{ name: 'refetch-vulnerabilities', args: [] }]); expect(wrapper.emitted('refetch-vulnerabilities')).toEqual([[]]);
}); });
}); });
}); });
......
...@@ -52,7 +52,7 @@ describe('Approval auth component', () => { ...@@ -52,7 +52,7 @@ describe('Approval auth component', () => {
}); });
it('does not emit anything', () => { it('does not emit anything', () => {
expect(wrapper.emittedByOrder()).toEqual([]); expect(wrapper.emitted()).toEqual({});
}); });
}); });
...@@ -67,7 +67,7 @@ describe('Approval auth component', () => { ...@@ -67,7 +67,7 @@ describe('Approval auth component', () => {
wrapper.find(GlModal).vm.$emit('ok', { preventDefault: () => null }); wrapper.find(GlModal).vm.$emit('ok', { preventDefault: () => null });
waitForTick(done); waitForTick(done);
expect(wrapper.emittedByOrder()).toEqual([{ name: 'approve', args: [TEST_PASSWORD] }]); expect(wrapper.emitted().approve).toEqual([[TEST_PASSWORD]]);
}); });
}); });
......
...@@ -141,7 +141,7 @@ describe('EE MRWidget approvals footer', () => { ...@@ -141,7 +141,7 @@ describe('EE MRWidget approvals footer', () => {
button.trigger('click'); button.trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toEqual([{ name: 'input', args: [true] }]); expect(wrapper.emitted().input).toEqual([[true]]);
}); });
}); });
}); });
...@@ -187,7 +187,7 @@ describe('EE MRWidget approvals footer', () => { ...@@ -187,7 +187,7 @@ describe('EE MRWidget approvals footer', () => {
wrapper.vm wrapper.vm
.$nextTick() .$nextTick()
.then(() => { .then(() => {
expect(wrapper.emittedByOrder()).toEqual([{ name: 'input', args: [true] }]); expect(wrapper.emitted().input).toEqual([[true]]);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Event Item with action buttons renders the action buttons 1`] = ` exports[`Event Item with action buttons renders the action buttons 1`] = `
VueWrapper { <div
"_emitted": Object {}, class="d-flex align-items-center"
"_emittedByOrder": Array [], >
"isFunctionalComponent": undefined, <div
} class="circle-icon-container ci-status-icon-success"
>
<svg
class="gl-icon s16"
data-testid="plus-icon"
>
<use
href="#plus"
/>
</svg>
</div>
<div
class="ml-3 flex-grow-1"
data-qa-selector="event_item_content"
>
<div
class="note-header-info pb-0"
>
<!---->
<a
class="author-name-link js-user-link"
data-username="gitlab"
>
<span
class="note-header-author-name bold"
>
Tanuki
</span>
</a>
<!---->
<span
class="text-nowrap author-username"
>
<a
class="author-username-link"
>
<span
class="note-headline-light"
>
@gitlab
</span>
</a>
<!---->
</span>
<span
class="note-headline-light note-headline-meta"
>
<span
class="system-note-message"
>
·
</span>
<!---->
<!---->
<!---->
</span>
</div>
</div>
<div>
<button
class="btn px-1 btn-transparent btn-md"
title="Foo Action"
type="button"
>
<!---->
<svg
class="link-highlight gl-icon s16"
data-testid="pencil-icon"
>
<use
href="#pencil"
/>
</svg>
</button>
<button
class="btn px-1 btn-transparent btn-md"
title="Bar Action"
type="button"
>
<!---->
<svg
class="link-highlight gl-icon s16"
data-testid="remove-icon"
>
<use
href="#remove"
/>
</svg>
</button>
</div>
</div>
`; `;
...@@ -86,7 +86,7 @@ describe('Event Item', () => { ...@@ -86,7 +86,7 @@ describe('Event Item', () => {
it('renders the action buttons', () => { it('renders the action buttons', () => {
expect(wrapper.findAll(GlDeprecatedButton)).toHaveLength(2); expect(wrapper.findAll(GlDeprecatedButton)).toHaveLength(2);
expect(wrapper).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
it('emits the button events when clicked', () => { it('emits the button events when clicked', () => {
......
...@@ -42,24 +42,24 @@ describe('IDE TerminalControls', () => { ...@@ -42,24 +42,24 @@ describe('IDE TerminalControls', () => {
it('emits "scroll-up" when click up button', () => { it('emits "scroll-up" when click up button', () => {
factory({ propsData: { canScrollUp: true } }); factory({ propsData: { canScrollUp: true } });
expect(wrapper.emittedByOrder()).toEqual([]); expect(wrapper.emitted()).toEqual({});
buttons.at(0).vm.$emit('click'); buttons.at(0).vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toEqual([{ name: 'scroll-up', args: [] }]); expect(wrapper.emitted('scroll-up')).toEqual([[]]);
}); });
}); });
it('emits "scroll-down" when click down button', () => { it('emits "scroll-down" when click down button', () => {
factory({ propsData: { canScrollDown: true } }); factory({ propsData: { canScrollDown: true } });
expect(wrapper.emittedByOrder()).toEqual([]); expect(wrapper.emitted()).toEqual({});
buttons.at(1).vm.$emit('click'); buttons.at(1).vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toEqual([{ name: 'scroll-down', args: [] }]); expect(wrapper.emitted('scroll-down')).toEqual([[]]);
}); });
}); });
}); });
...@@ -121,8 +121,6 @@ describe('EnvironmentLogs', () => { ...@@ -121,8 +121,6 @@ describe('EnvironmentLogs', () => {
it('displays UI elements', () => { it('displays UI elements', () => {
initWrapper(); initWrapper();
expect(wrapper.isEmpty()).toBe(false);
expect(findEnvironmentsDropdown().is(GlDeprecatedDropdown)).toBe(true); expect(findEnvironmentsDropdown().is(GlDeprecatedDropdown)).toBe(true);
expect(findSimpleFilters().exists()).toBe(true); expect(findSimpleFilters().exists()).toBe(true);
expect(findLogControlButtons().exists()).toBe(true); expect(findLogControlButtons().exists()).toBe(true);
......
...@@ -68,8 +68,6 @@ describe('LogAdvancedFilters', () => { ...@@ -68,8 +68,6 @@ describe('LogAdvancedFilters', () => {
it('displays UI elements', () => { it('displays UI elements', () => {
initWrapper(); initWrapper();
expect(wrapper.isEmpty()).toBe(false);
expect(findFilteredSearch().exists()).toBe(true); expect(findFilteredSearch().exists()).toBe(true);
expect(findTimeRangePicker().exists()).toBe(true); expect(findTimeRangePicker().exists()).toBe(true);
}); });
......
...@@ -28,8 +28,6 @@ describe('LogControlButtons', () => { ...@@ -28,8 +28,6 @@ describe('LogControlButtons', () => {
it('displays UI elements', () => { it('displays UI elements', () => {
initWrapper(); initWrapper();
expect(wrapper.isEmpty()).toBe(false);
expect(findScrollToTop().is(GlButton)).toBe(true); expect(findScrollToTop().is(GlButton)).toBe(true);
expect(findScrollToBottom().is(GlButton)).toBe(true); expect(findScrollToBottom().is(GlButton)).toBe(true);
expect(findRefreshBtn().is(GlButton)).toBe(true); expect(findRefreshBtn().is(GlButton)).toBe(true);
......
...@@ -59,8 +59,6 @@ describe('LogSimpleFilters', () => { ...@@ -59,8 +59,6 @@ describe('LogSimpleFilters', () => {
it('displays UI elements', () => { it('displays UI elements', () => {
initWrapper(); initWrapper();
expect(wrapper.isEmpty()).toBe(false);
expect(findPodsDropdown().exists()).toBe(true); expect(findPodsDropdown().exists()).toBe(true);
}); });
......
...@@ -47,8 +47,6 @@ describe('Pipelines filtered search', () => { ...@@ -47,8 +47,6 @@ describe('Pipelines filtered search', () => {
}); });
it('displays UI elements', () => { it('displays UI elements', () => {
expect(wrapper.isEmpty()).toBe(false);
expect(findFilteredSearch().exists()).toBe(true); expect(findFilteredSearch().exists()).toBe(true);
}); });
......
...@@ -77,10 +77,7 @@ describe('Suggestion Diff component', () => { ...@@ -77,10 +77,7 @@ describe('Suggestion Diff component', () => {
}); });
it('emits apply', () => { it('emits apply', () => {
expect(wrapper.emittedByOrder()).toContainEqual({ expect(wrapper.emitted().apply).toEqual([[expect.any(Function)]]);
name: 'apply',
args: [expect.any(Function)],
});
}); });
it('does not render apply suggestion and add to batch buttons', () => { it('does not render apply suggestion and add to batch buttons', () => {
...@@ -111,10 +108,7 @@ describe('Suggestion Diff component', () => { ...@@ -111,10 +108,7 @@ describe('Suggestion Diff component', () => {
findAddToBatchButton().vm.$emit('click'); findAddToBatchButton().vm.$emit('click');
expect(wrapper.emittedByOrder()).toContainEqual({ expect(wrapper.emitted().addToBatch).toEqual([[]]);
name: 'addToBatch',
args: [],
});
}); });
}); });
...@@ -124,10 +118,7 @@ describe('Suggestion Diff component', () => { ...@@ -124,10 +118,7 @@ describe('Suggestion Diff component', () => {
findRemoveFromBatchButton().vm.$emit('click'); findRemoveFromBatchButton().vm.$emit('click');
expect(wrapper.emittedByOrder()).toContainEqual({ expect(wrapper.emitted().removeFromBatch).toEqual([[]]);
name: 'removeFromBatch',
args: [],
});
}); });
}); });
...@@ -137,10 +128,7 @@ describe('Suggestion Diff component', () => { ...@@ -137,10 +128,7 @@ describe('Suggestion Diff component', () => {
findApplyBatchButton().vm.$emit('click'); findApplyBatchButton().vm.$emit('click');
expect(wrapper.emittedByOrder()).toContainEqual({ expect(wrapper.emitted().applyBatch).toEqual([[]]);
name: 'applyBatch',
args: [],
});
}); });
}); });
......
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