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', () => {
clickItemAt(1);
clickItemAt(2);
expect(wrapper.emittedByOrder()).toEqual([
{ name: 'selected', args: [transformedStagePathData[0]] },
{ name: 'selected', args: [transformedStagePathData[1]] },
{ name: 'selected', args: [transformedStagePathData[2]] },
expect(wrapper.emitted().selected).toEqual([
[transformedStagePathData[0]],
[transformedStagePathData[1]],
[transformedStagePathData[2]],
]);
});
});
......
......@@ -49,12 +49,7 @@ describe('StageDropdownFilter component', () => {
it('should remove from selection', () => {
selectDropdownItemAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [[stages[1], stages[2]]],
},
]);
expect(wrapper.emitted().selected).toEqual([[[stages[1], stages[2]]]]);
});
});
......@@ -66,15 +61,9 @@ describe('StageDropdownFilter component', () => {
it('should add to selection', () => {
selectDropdownItemAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [[stages[1], stages[2]]],
},
{
name: 'selected',
args: [[stages[1], stages[2], stages[0]]],
},
expect(wrapper.emitted().selected).toEqual([
[[stages[1], stages[2]]],
[[stages[1], stages[2], stages[0]]],
]);
});
});
......
......@@ -60,12 +60,7 @@ describe('Daterange component', () => {
input.trigger('change');
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'change',
args: [{ startDate: minDate, endDate }],
},
]);
expect(wrapper.emitted().change).toEqual([[{ startDate: minDate, endDate }]]);
});
});
});
......@@ -101,12 +96,7 @@ describe('Daterange component', () => {
const endDate = new Date('2019-10-05');
wrapper.vm.dateRange = { startDate, endDate };
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'change',
args: [{ startDate, endDate }],
},
]);
expect(wrapper.emitted().change).toEqual([[{ startDate, endDate }]]);
});
});
......
......@@ -109,23 +109,13 @@ describe('GroupsDropdownFilter component', () => {
it('should emit the "selected" event with the selected group', () => {
selectDropdownAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [groups[0]],
},
]);
expect(wrapper.emitted().selected).toEqual([[groups[0]]]);
});
it('should change selection when new group is clicked', () => {
selectDropdownAtIndex(1);
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [groups[1]],
},
]);
expect(wrapper.emitted().selected).toEqual([[groups[1]]]);
});
it('renders an avatar in the dropdown button when the group has an avatar_url', () => {
......
......@@ -131,39 +131,20 @@ describe('ProjectsDropdownFilter component', () => {
it('should emit the "selected" event with the selected project', () => {
selectDropdownItemAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [[projects[0]]],
},
]);
expect(wrapper.emitted().selected).toEqual([[[projects[0]]]]);
});
it('should change selection when new project is clicked', () => {
selectDropdownItemAtIndex(1);
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [[projects[1]]],
},
]);
expect(wrapper.emitted().selected).toEqual([[[projects[1]]]]);
});
it('selection should be emptied when a project is deselected', () => {
selectDropdownItemAtIndex(0); // Select the item
selectDropdownItemAtIndex(0); // deselect it
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [[projects[0]]],
},
{
name: 'selected',
args: [[]],
},
]);
expect(wrapper.emitted().selected).toEqual([[[projects[0]]], [[]]]);
});
it('renders an avatar in the dropdown button when the project has an avatar_url', () => {
......@@ -212,32 +193,14 @@ describe('ProjectsDropdownFilter component', () => {
selectDropdownItemAtIndex(0);
selectDropdownItemAtIndex(1);
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [[projects[0]]],
},
{
name: 'selected',
args: [[projects[0], projects[1]]],
},
]);
expect(wrapper.emitted().selected).toEqual([[[projects[0]]], [[projects[0], projects[1]]]]);
});
it('should remove from selection when clicked again', () => {
selectDropdownItemAtIndex(0);
selectDropdownItemAtIndex(0);
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [[projects[0]]],
},
{
name: 'selected',
args: [[]],
},
]);
expect(wrapper.emitted().selected).toEqual([[[projects[0]]], [[]]]);
});
it('renders the correct placeholder text when multiple projects are selected', () => {
......
......@@ -51,7 +51,7 @@ describe('Approvals ApproversListItem', () => {
button.vm.$emit('click');
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', () => {
return wrapper.vm.$nextTick().then(() => {
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', () => {
{ ...TEST_USERS[0], type: TYPE_USER },
{ ...TEST_GROUPS[0], type: TYPE_GROUP },
];
const expected = expectedFinal.map((x, idx) => ({
name: 'input',
args: [expectedFinal.slice(0, idx + 1)],
}));
const expected = expectedFinal.map((x, idx) => [expectedFinal.slice(0, idx + 1)]);
waitForEvent($input, 'select2-loaded')
.then(() => {
......@@ -191,7 +188,7 @@ describe('Approvals ApproversSelect', () => {
waitForEvent($input, 'change')
.then(jest.runOnlyPendingTimers)
.then(() => {
expect(wrapper.emittedByOrder()).toEqual(expected);
expect(wrapper.emitted().input).toEqual(expected);
})
.then(done)
.catch(done.fail);
......
......@@ -121,12 +121,7 @@ describe('Branches Select', () => {
const selectedIndex = 1;
const selectedId = TEST_BRANCHES_SELECTIONS[selectedIndex].id;
const expected = [
{
name: 'input',
args: [selectedId],
},
];
const expected = [[selectedId]];
waitForEvent($input, 'select2-loaded')
.then(() => {
......@@ -138,7 +133,7 @@ describe('Branches Select', () => {
waitForEvent($input, 'change')
.then(() => {
expect(wrapper.emittedByOrder()).toEqual(expected);
expect(wrapper.emitted().input).toEqual(expected);
})
.then(done)
.catch(done.fail);
......
......@@ -52,12 +52,7 @@ describe('project header component', () => {
wrapper.find('.js-remove-button').vm.$emit('click');
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toContainEqual(
expect.objectContaining({
name: 'remove',
args: [mockOneProject.remove_path],
}),
);
expect(wrapper.emitted().remove).toStrictEqual([[mockOneProject.remove_path]]);
});
});
});
......
......@@ -128,10 +128,8 @@ describe('Selection Summary component', () => {
it('should emit an event to refetch the vulnerabilities when the request is successful', () => {
dismissButton().trigger('submit');
return waitForPromises().then(() => {
expect(wrapper.emittedByOrder()).toEqual([
{ name: 'deselect-all-vulnerabilities', args: [] },
{ name: 'refetch-vulnerabilities', args: [] },
]);
expect(wrapper.emitted('deselect-all-vulnerabilities')).toEqual([[]]);
expect(wrapper.emitted('refetch-vulnerabilities')).toEqual([[]]);
});
});
......@@ -139,7 +137,7 @@ describe('Selection Summary component', () => {
mutateMock.mockRejectedValue();
dismissButton().trigger('submit');
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', () => {
});
it('does not emit anything', () => {
expect(wrapper.emittedByOrder()).toEqual([]);
expect(wrapper.emitted()).toEqual({});
});
});
......@@ -67,7 +67,7 @@ describe('Approval auth component', () => {
wrapper.find(GlModal).vm.$emit('ok', { preventDefault: () => null });
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', () => {
button.trigger('click');
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', () => {
wrapper.vm
.$nextTick()
.then(() => {
expect(wrapper.emittedByOrder()).toEqual([{ name: 'input', args: [true] }]);
expect(wrapper.emitted().input).toEqual([[true]]);
})
.then(done)
.catch(done.fail);
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Event Item with action buttons renders the action buttons 1`] = `
VueWrapper {
"_emitted": Object {},
"_emittedByOrder": Array [],
"isFunctionalComponent": undefined,
}
<div
class="d-flex align-items-center"
>
<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', () => {
it('renders the action buttons', () => {
expect(wrapper.findAll(GlDeprecatedButton)).toHaveLength(2);
expect(wrapper).toMatchSnapshot();
expect(wrapper.element).toMatchSnapshot();
});
it('emits the button events when clicked', () => {
......
......@@ -42,24 +42,24 @@ describe('IDE TerminalControls', () => {
it('emits "scroll-up" when click up button', () => {
factory({ propsData: { canScrollUp: true } });
expect(wrapper.emittedByOrder()).toEqual([]);
expect(wrapper.emitted()).toEqual({});
buttons.at(0).vm.$emit('click');
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', () => {
factory({ propsData: { canScrollDown: true } });
expect(wrapper.emittedByOrder()).toEqual([]);
expect(wrapper.emitted()).toEqual({});
buttons.at(1).vm.$emit('click');
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', () => {
it('displays UI elements', () => {
initWrapper();
expect(wrapper.isEmpty()).toBe(false);
expect(findEnvironmentsDropdown().is(GlDeprecatedDropdown)).toBe(true);
expect(findSimpleFilters().exists()).toBe(true);
expect(findLogControlButtons().exists()).toBe(true);
......
......@@ -68,8 +68,6 @@ describe('LogAdvancedFilters', () => {
it('displays UI elements', () => {
initWrapper();
expect(wrapper.isEmpty()).toBe(false);
expect(findFilteredSearch().exists()).toBe(true);
expect(findTimeRangePicker().exists()).toBe(true);
});
......
......@@ -28,8 +28,6 @@ describe('LogControlButtons', () => {
it('displays UI elements', () => {
initWrapper();
expect(wrapper.isEmpty()).toBe(false);
expect(findScrollToTop().is(GlButton)).toBe(true);
expect(findScrollToBottom().is(GlButton)).toBe(true);
expect(findRefreshBtn().is(GlButton)).toBe(true);
......
......@@ -59,8 +59,6 @@ describe('LogSimpleFilters', () => {
it('displays UI elements', () => {
initWrapper();
expect(wrapper.isEmpty()).toBe(false);
expect(findPodsDropdown().exists()).toBe(true);
});
......
......@@ -47,8 +47,6 @@ describe('Pipelines filtered search', () => {
});
it('displays UI elements', () => {
expect(wrapper.isEmpty()).toBe(false);
expect(findFilteredSearch().exists()).toBe(true);
});
......
......@@ -77,10 +77,7 @@ describe('Suggestion Diff component', () => {
});
it('emits apply', () => {
expect(wrapper.emittedByOrder()).toContainEqual({
name: 'apply',
args: [expect.any(Function)],
});
expect(wrapper.emitted().apply).toEqual([[expect.any(Function)]]);
});
it('does not render apply suggestion and add to batch buttons', () => {
......@@ -111,10 +108,7 @@ describe('Suggestion Diff component', () => {
findAddToBatchButton().vm.$emit('click');
expect(wrapper.emittedByOrder()).toContainEqual({
name: 'addToBatch',
args: [],
});
expect(wrapper.emitted().addToBatch).toEqual([[]]);
});
});
......@@ -124,10 +118,7 @@ describe('Suggestion Diff component', () => {
findRemoveFromBatchButton().vm.$emit('click');
expect(wrapper.emittedByOrder()).toContainEqual({
name: 'removeFromBatch',
args: [],
});
expect(wrapper.emitted().removeFromBatch).toEqual([[]]);
});
});
......@@ -137,10 +128,7 @@ describe('Suggestion Diff component', () => {
findApplyBatchButton().vm.$emit('click');
expect(wrapper.emittedByOrder()).toContainEqual({
name: 'applyBatch',
args: [],
});
expect(wrapper.emitted().applyBatch).toEqual([[]]);
});
});
......
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