Commit a0f2c5ba authored by Mike Greiling's avatar Mike Greiling

Merge branch 'leipert-object-assign-spec' into 'master'

Use Object spread over Object.assign in spec/

See merge request gitlab-org/gitlab!31356
parents 108a4865 89ba3161
......@@ -15,7 +15,7 @@ describe('Api', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
originalGon = window.gon;
window.gon = Object.assign({}, dummyGon);
window.gon = { ...dummyGon };
});
afterEach(() => {
......
......@@ -38,7 +38,7 @@ describe('Blob Content component', () => {
it('renders error if there is any in the viewer', () => {
const renderError = 'Oops';
const viewer = Object.assign({}, SimpleViewerMock, { renderError });
const viewer = { ...SimpleViewerMock, renderError };
createComponent({}, viewer);
expect(wrapper.contains(GlLoadingIcon)).toBe(false);
expect(wrapper.contains(BlobContentError)).toBe(true);
......
......@@ -15,7 +15,7 @@ describe('Blob Header Filepath', () => {
function createComponent(blobProps = {}, options = {}) {
wrapper = shallowMount(BlobHeaderFilepath, {
propsData: {
blob: Object.assign({}, MockBlob, blobProps),
blob: { ...MockBlob, ...blobProps },
},
...options,
});
......
......@@ -13,7 +13,7 @@ describe('Blob Header Default Actions', () => {
const method = shouldMount ? mount : shallowMount;
wrapper = method.call(this, BlobHeader, {
propsData: {
blob: Object.assign({}, Blob, blobProps),
blob: { ...Blob, ...blobProps },
...propsData,
},
...options,
......
......@@ -64,7 +64,7 @@ describe('Board list component', () => {
let getIssues;
function generateIssues(compWrapper) {
for (let i = 1; i < 20; i += 1) {
const issue = Object.assign({}, compWrapper.list.issues[0]);
const issue = { ...compWrapper.list.issues[0] };
issue.id += i;
compWrapper.list.issues.push(issue);
}
......
......@@ -93,7 +93,7 @@ describe('KnativeDomainEditor', () => {
it('displays toast indicating a successful update', () => {
wrapper.vm.$toast = { show: jest.fn() };
wrapper.setProps({ knative: Object.assign({ updateSuccessful: true }, knative) });
wrapper.setProps({ knative: { updateSuccessful: true, ...knative } });
return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.$toast.show).toHaveBeenCalledWith(
......
......@@ -118,7 +118,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
let pipelineCopy;
beforeEach(() => {
pipelineCopy = Object.assign({}, pipeline);
pipelineCopy = { ...pipeline };
});
describe('when latest pipeline has detached flag and canRunPipeline is true', () => {
......@@ -128,12 +128,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
mock.onGet('endpoint.json').reply(200, [pipelineCopy]);
vm = mountComponent(
PipelinesTable,
Object.assign({}, props, {
canRunPipeline: true,
}),
);
vm = mountComponent(PipelinesTable, { ...props, canRunPipeline: true });
setImmediate(() => {
expect(vm.$el.querySelector('.js-run-mr-pipeline')).not.toBeNull();
......@@ -149,12 +144,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
mock.onGet('endpoint.json').reply(200, [pipelineCopy]);
vm = mountComponent(
PipelinesTable,
Object.assign({}, props, {
canRunPipeline: false,
}),
);
vm = mountComponent(PipelinesTable, { ...props, canRunPipeline: false });
setImmediate(() => {
expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull();
......@@ -170,12 +160,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
mock.onGet('endpoint.json').reply(200, [pipelineCopy]);
vm = mountComponent(
PipelinesTable,
Object.assign({}, props, {
canRunPipeline: true,
}),
);
vm = mountComponent(PipelinesTable, { ...props, canRunPipeline: true });
setImmediate(() => {
expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull();
......@@ -191,12 +176,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
mock.onGet('endpoint.json').reply(200, [pipelineCopy]);
vm = mountComponent(
PipelinesTable,
Object.assign({}, props, {
canRunPipeline: false,
}),
);
vm = mountComponent(PipelinesTable, { ...props, canRunPipeline: false });
setImmediate(() => {
expect(vm.$el.querySelector('.js-run-mr-pipeline')).toBeNull();
......@@ -211,14 +191,12 @@ describe('Pipelines table in Commits and Merge requests', () => {
mock.onGet('endpoint.json').reply(200, [pipelineCopy]);
vm = mountComponent(
PipelinesTable,
Object.assign({}, props, {
canRunPipeline: true,
projectId: '5',
mergeRequestId: 3,
}),
);
vm = mountComponent(PipelinesTable, {
...props,
canRunPipeline: true,
projectId: '5',
mergeRequestId: 3,
});
});
it('updates the loading state', done => {
......
......@@ -13,7 +13,7 @@ const localVue = createLocalVue();
describe('DiffDiscussions', () => {
let store;
let wrapper;
const getDiscussionsMockData = () => [Object.assign({}, discussionsMockData)];
const getDiscussionsMockData = () => [{ ...discussionsMockData }];
const createComponent = props => {
store = createStore();
......
......@@ -81,7 +81,7 @@ describe('DiffExpansionCell', () => {
isTop: false,
isBottom: false,
};
const props = Object.assign({}, defaults, options);
const props = { ...defaults, ...options };
vm = createComponentWithStore(cmp, store, props).$mount();
};
......
......@@ -2,7 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import DiffGutterAvatars from '~/diffs/components/diff_gutter_avatars.vue';
import discussionsMockData from '../mock_data/diff_discussions';
const getDiscussionsMockData = () => [Object.assign({}, discussionsMockData)];
const getDiscussionsMockData = () => [{ ...discussionsMockData }];
describe('DiffGutterAvatars', () => {
let wrapper;
......
......@@ -9,7 +9,7 @@ describe('DiffLineNoteForm', () => {
let wrapper;
let diffFile;
let diffLines;
const getDiffFileMock = () => Object.assign({}, diffFileMockData);
const getDiffFileMock = () => ({ ...diffFileMockData });
beforeEach(() => {
diffFile = getDiffFileMock();
......
......@@ -16,7 +16,7 @@ describe('InlineDiffExpansionRow', () => {
isTop: false,
isBottom: false,
};
const props = Object.assign({}, defaults, options);
const props = { ...defaults, ...options };
return createComponentWithStore(cmp, createStore(), props).$mount();
};
......
......@@ -8,8 +8,8 @@ import discussionsMockData from '../mock_data/diff_discussions';
describe('InlineDiffView', () => {
let component;
const getDiffFileMock = () => Object.assign({}, diffFileMockData);
const getDiscussionsMockData = () => [Object.assign({}, discussionsMockData)];
const getDiffFileMock = () => ({ ...diffFileMockData });
const getDiscussionsMockData = () => [{ ...discussionsMockData }];
const notesLength = getDiscussionsMockData()[0].notes.length;
beforeEach(done => {
......
......@@ -16,7 +16,7 @@ describe('ParallelDiffExpansionRow', () => {
isTop: false,
isBottom: false,
};
const props = Object.assign({}, defaults, options);
const props = { ...defaults, ...options };
return createComponentWithStore(cmp, createStore(), props).$mount();
};
......
......@@ -7,7 +7,7 @@ import diffFileMockData from '../mock_data/diff_file';
describe('ParallelDiffView', () => {
let component;
const getDiffFileMock = () => Object.assign({}, diffFileMockData);
const getDiffFileMock = () => ({ ...diffFileMockData });
beforeEach(() => {
const diffFile = getDiffFileMock();
......
......@@ -14,10 +14,10 @@ describe('Diffs Module Getters', () => {
beforeEach(() => {
localState = state();
discussionMock = Object.assign({}, discussion);
discussionMock = { ...discussion };
discussionMock.diff_file.file_hash = diffFileMock.fileHash;
discussionMock1 = Object.assign({}, discussion);
discussionMock1 = { ...discussion };
discussionMock1.diff_file.file_hash = diffFileMock.fileHash;
});
......
......@@ -372,13 +372,13 @@ describe('DiffsStoreUtils', () => {
mock = getDiffFileMock();
preparedDiff = { diff_files: [mock] };
splitInlineDiff = {
diff_files: [Object.assign({}, mock, { parallel_diff_lines: undefined })],
diff_files: [{ ...mock, parallel_diff_lines: undefined }],
};
splitParallelDiff = {
diff_files: [Object.assign({}, mock, { highlighted_diff_lines: undefined })],
diff_files: [{ ...mock, highlighted_diff_lines: undefined }],
};
completedDiff = {
diff_files: [Object.assign({}, mock, { highlighted_diff_lines: undefined })],
diff_files: [{ ...mock, highlighted_diff_lines: undefined }],
};
preparedDiff.diff_files = utils.prepareDiffData(preparedDiff);
......
......@@ -216,7 +216,7 @@ describe('AppComponent', () => {
let groupItem;
beforeEach(() => {
groupItem = Object.assign({}, mockParentGroupItem);
groupItem = { ...mockParentGroupItem };
groupItem.isOpen = false;
groupItem.isChildrenLoading = false;
});
......@@ -271,7 +271,7 @@ describe('AppComponent', () => {
describe('showLeaveGroupModal', () => {
it('caches candidate group (as props) which is to be left', () => {
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
expect(vm.targetGroup).toBe(null);
expect(vm.targetParentGroup).toBe(null);
......@@ -282,7 +282,7 @@ describe('AppComponent', () => {
});
it('updates props which show modal confirmation dialog', () => {
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
expect(vm.showModal).toBe(false);
expect(vm.groupLeaveConfirmationMessage).toBe('');
......@@ -297,7 +297,7 @@ describe('AppComponent', () => {
describe('hideLeaveGroupModal', () => {
it('hides modal confirmation which is shown before leaving the group', () => {
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
vm.showLeaveGroupModal(group, mockParentGroupItem);
expect(vm.showModal).toBe(true);
......@@ -312,7 +312,7 @@ describe('AppComponent', () => {
let childGroupItem;
beforeEach(() => {
groupItem = Object.assign({}, mockParentGroupItem);
groupItem = { ...mockParentGroupItem };
groupItem.children = mockChildren;
[childGroupItem] = groupItem.children;
groupItem.isChildrenLoading = false;
......
......@@ -52,7 +52,7 @@ describe('GroupFolderComponent', () => {
});
it('should render more children link when groups list has children over MAX_CHILDREN_COUNT limit', () => {
const parentGroup = Object.assign({}, mockParentGroupItem);
const parentGroup = { ...mockParentGroupItem };
parentGroup.childrenCount = 21;
const newVm = createComponent(mockGroups, parentGroup);
......
......@@ -52,7 +52,7 @@ describe('GroupItemComponent', () => {
describe('hasChildren', () => {
it('should return boolean value representing if group has any children present', () => {
let newVm;
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
group.childrenCount = 5;
newVm = createComponent(group);
......@@ -71,7 +71,7 @@ describe('GroupItemComponent', () => {
describe('hasAvatar', () => {
it('should return boolean value representing if group has any avatar present', () => {
let newVm;
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
group.avatarUrl = null;
newVm = createComponent(group);
......@@ -90,7 +90,7 @@ describe('GroupItemComponent', () => {
describe('isGroup', () => {
it('should return boolean value representing if group item is of type `group` or not', () => {
let newVm;
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
group.type = 'group';
newVm = createComponent(group);
......@@ -138,7 +138,7 @@ describe('GroupItemComponent', () => {
it('should navigate page to group homepage if group does not have any children present', () => {
jest.spyOn(urlUtilities, 'visitUrl').mockImplementation();
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
group.childrenCount = 0;
const newVm = createComponent(group);
jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
......
......@@ -46,7 +46,7 @@ describe('ItemActionsComponent', () => {
});
it('should render Edit Group button with correct attribute values', () => {
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
group.canEdit = true;
const newVm = createComponent(group);
......@@ -64,7 +64,7 @@ describe('ItemActionsComponent', () => {
});
it('should render Leave Group button with correct attribute values', () => {
const group = Object.assign({}, mockParentGroupItem);
const group = { ...mockParentGroupItem };
group.canLeave = true;
const newVm = createComponent(group);
......
......@@ -23,7 +23,7 @@ describe('ItemStatsComponent', () => {
describe('visibilityIcon', () => {
it('should return icon class based on `item.visibility` value', () => {
Object.keys(VISIBILITY_TYPE_ICON).forEach(visibility => {
const item = Object.assign({}, mockParentGroupItem, { visibility });
const item = { ...mockParentGroupItem, visibility };
const vm = createComponent(item);
expect(vm.visibilityIcon).toBe(VISIBILITY_TYPE_ICON[visibility]);
......@@ -35,10 +35,7 @@ describe('ItemStatsComponent', () => {
describe('visibilityTooltip', () => {
it('should return tooltip string for Group based on `item.visibility` value', () => {
Object.keys(GROUP_VISIBILITY_TYPE).forEach(visibility => {
const item = Object.assign({}, mockParentGroupItem, {
visibility,
type: ITEM_TYPE.GROUP,
});
const item = { ...mockParentGroupItem, visibility, type: ITEM_TYPE.GROUP };
const vm = createComponent(item);
expect(vm.visibilityTooltip).toBe(GROUP_VISIBILITY_TYPE[visibility]);
......@@ -48,10 +45,7 @@ describe('ItemStatsComponent', () => {
it('should return tooltip string for Project based on `item.visibility` value', () => {
Object.keys(PROJECT_VISIBILITY_TYPE).forEach(visibility => {
const item = Object.assign({}, mockParentGroupItem, {
visibility,
type: ITEM_TYPE.PROJECT,
});
const item = { ...mockParentGroupItem, visibility, type: ITEM_TYPE.PROJECT };
const vm = createComponent(item);
expect(vm.visibilityTooltip).toBe(PROJECT_VISIBILITY_TYPE[visibility]);
......@@ -65,13 +59,13 @@ describe('ItemStatsComponent', () => {
let item;
let vm;
item = Object.assign({}, mockParentGroupItem, { type: ITEM_TYPE.PROJECT });
item = { ...mockParentGroupItem, type: ITEM_TYPE.PROJECT };
vm = createComponent(item);
expect(vm.isProject).toBeTruthy();
vm.$destroy();
item = Object.assign({}, mockParentGroupItem, { type: ITEM_TYPE.GROUP });
item = { ...mockParentGroupItem, type: ITEM_TYPE.GROUP };
vm = createComponent(item);
expect(vm.isProject).toBeFalsy();
......@@ -84,13 +78,13 @@ describe('ItemStatsComponent', () => {
let item;
let vm;
item = Object.assign({}, mockParentGroupItem, { type: ITEM_TYPE.GROUP });
item = { ...mockParentGroupItem, type: ITEM_TYPE.GROUP };
vm = createComponent(item);
expect(vm.isGroup).toBeTruthy();
vm.$destroy();
item = Object.assign({}, mockParentGroupItem, { type: ITEM_TYPE.PROJECT });
item = { ...mockParentGroupItem, type: ITEM_TYPE.PROJECT };
vm = createComponent(item);
expect(vm.isGroup).toBeFalsy();
......@@ -109,10 +103,7 @@ describe('ItemStatsComponent', () => {
});
it('renders start count and last updated information for project item correctly', () => {
const item = Object.assign({}, mockParentGroupItem, {
type: ITEM_TYPE.PROJECT,
starCount: 4,
});
const item = { ...mockParentGroupItem, type: ITEM_TYPE.PROJECT, starCount: 4 };
const vm = createComponent(item);
const projectStarIconEl = vm.$el.querySelector('.project-stars');
......
......@@ -27,7 +27,7 @@ describe('ItemStatsValueComponent', () => {
describe('isValuePresent', () => {
it('returns true if non-empty `value` is present', () => {
vm = createComponent(Object.assign({}, itemConfig, { value: 10 }));
vm = createComponent({ ...itemConfig, value: 10 });
expect(vm.isValuePresent).toBeTruthy();
});
......
......@@ -108,8 +108,8 @@ describe('ProjectsStore', () => {
describe('removeGroup', () => {
it('should remove children from group item in state', () => {
const store = new GroupsStore();
const rawParentGroup = Object.assign({}, mockGroups[0]);
const rawChildGroup = Object.assign({}, mockGroups[1]);
const rawParentGroup = { ...mockGroups[0] };
const rawChildGroup = { ...mockGroups[1] };
store.setGroups([rawParentGroup]);
store.setGroupChildren(store.state.groups[0], [rawChildGroup]);
......
......@@ -15,7 +15,7 @@ describe('IDE review mode', () => {
store = createStore();
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.projects.abcproject = Object.assign({}, projectData);
store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', {
tree: [file('fileName')],
loading: false,
......
......@@ -10,7 +10,7 @@ function bootstrap(projData) {
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.projects.abcproject = Object.assign({}, projData);
store.state.projects.abcproject = { ...projData };
Vue.set(store.state.trees, 'abcproject/master', {
tree: [],
loading: false,
......@@ -27,7 +27,7 @@ describe('ide component, empty repo', () => {
let vm;
beforeEach(() => {
const emptyProjData = Object.assign({}, projectData, { empty_repo: true, branches: {} });
const emptyProjData = { ...projectData, empty_repo: true, branches: {} };
vm = bootstrap(emptyProjData);
vm.$mount();
});
......
......@@ -14,7 +14,7 @@ describe('IDE tree list', () => {
const bootstrapWithTree = (tree = normalBranchTree) => {
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.projects.abcproject = Object.assign({}, projectData);
store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', {
tree,
loading: false,
......
......@@ -13,7 +13,7 @@ describe('IdeRepoTree', () => {
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
store.state.projects.abcproject = Object.assign({}, projectData);
store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', {
tree: [file('fileName')],
loading: false,
......
......@@ -17,11 +17,12 @@ describe('ImportProjectsTable', () => {
};
function initStore() {
const stubbedActions = Object.assign({}, actions, {
const stubbedActions = {
...actions,
fetchJobs: jest.fn(),
fetchRepos: jest.fn(actions.requestRepos),
fetchImport: jest.fn(actions.requestImport),
});
};
const store = new Vuex.Store({
state: state(),
......
......@@ -18,9 +18,7 @@ describe('ProviderRepoTableRow', () => {
};
function initStore() {
const stubbedActions = Object.assign({}, actions, {
fetchImport,
});
const stubbedActions = { ...actions, fetchImport };
const store = new Vuex.Store({
state: state(),
......
......@@ -13,7 +13,7 @@ describe('ActiveToggle', () => {
const createComponent = props => {
wrapper = mount(ActiveToggle, {
propsData: Object.assign({}, defaultProps, props),
propsData: { ...defaultProps, ...props },
});
};
......
......@@ -13,7 +13,7 @@ describe('JiraTriggerFields', () => {
const createComponent = props => {
wrapper = mount(JiraTriggerFields, {
propsData: Object.assign({}, defaultProps, props),
propsData: { ...defaultProps, ...props },
});
};
......
......@@ -113,12 +113,7 @@ describe('Description component', () => {
beforeEach(() => {
vm.$destroy();
TaskList.mockClear();
vm = mountComponent(
DescriptionComponent,
Object.assign({}, props, {
issuableType: 'issuableType',
}),
);
vm = mountComponent(DescriptionComponent, { ...props, issuableType: 'issuableType' });
});
it('re-inits the TaskList when description changed', () => {
......
......@@ -86,7 +86,7 @@ describe('Job Log Header Line', () => {
describe('with duration', () => {
beforeEach(() => {
createComponent(Object.assign({}, data, { duration: '00:10' }));
createComponent({ ...data, duration: '00:10' });
});
it('renders the duration badge', () => {
......
......@@ -59,7 +59,7 @@ describe('Jobs Store Mutations', () => {
describe('when traceSize is bigger than the total size', () => {
it('sets isTraceSizeVisible to false', () => {
const copy = Object.assign({}, stateCopy, { traceSize: 5118460, size: 2321312 });
const copy = { ...stateCopy, traceSize: 5118460, size: 2321312 };
mutations[types.RECEIVE_TRACE_SUCCESS](copy, { total: 511846 });
......
......@@ -503,7 +503,7 @@ describe('common_utils', () => {
beforeEach(() => {
window.gon = window.gon || {};
beforeGon = Object.assign({}, window.gon);
beforeGon = { ...window.gon };
window.gon.sprite_icons = 'icons.svg';
});
......
......@@ -138,7 +138,7 @@ describe('noteable_discussion component', () => {
describe('signout widget', () => {
beforeEach(() => {
originalGon = Object.assign({}, window.gon);
originalGon = { ...window.gon };
window.gon = window.gon || {};
});
......
......@@ -193,7 +193,7 @@ describe.skip('Old Notes (~/notes.js)', () => {
$('.js-comment-button').click();
const $targetNote = $notesContainer.find(`#note_${noteEntity.id}`);
const updatedNote = Object.assign({}, noteEntity);
const updatedNote = { ...noteEntity };
updatedNote.note = 'bar';
notes.updateNote(updatedNote, $targetNote);
......
......@@ -18,9 +18,7 @@ describe('Collapse utils', () => {
});
it('returns false when a system note is not a description type', () => {
expect(isDescriptionSystemNote(Object.assign({}, mockSystemNote, { note: 'foo' }))).toEqual(
false,
);
expect(isDescriptionSystemNote({ ...mockSystemNote, note: 'foo' })).toEqual(false);
});
it('gets the time difference between two notes', () => {
......
......@@ -50,7 +50,7 @@ describe('Notes Store mutations', () => {
});
describe('ADD_NEW_REPLY_TO_DISCUSSION', () => {
const newReply = Object.assign({}, note, { discussion_id: discussionMock.id });
const newReply = { ...note, discussion_id: discussionMock.id };
let state;
......@@ -86,7 +86,7 @@ describe('Notes Store mutations', () => {
describe('EXPAND_DISCUSSION', () => {
it('should expand a collapsed discussion', () => {
const discussion = Object.assign({}, discussionMock, { expanded: false });
const discussion = { ...discussionMock, expanded: false };
const state = {
discussions: [discussion],
......@@ -100,7 +100,7 @@ describe('Notes Store mutations', () => {
describe('COLLAPSE_DISCUSSION', () => {
it('should collapse an expanded discussion', () => {
const discussion = Object.assign({}, discussionMock, { expanded: true });
const discussion = { ...discussionMock, expanded: true };
const state = {
discussions: [discussion],
......@@ -114,7 +114,7 @@ describe('Notes Store mutations', () => {
describe('REMOVE_PLACEHOLDER_NOTES', () => {
it('should remove all placeholder notes in indivudal notes and discussion', () => {
const placeholderNote = Object.assign({}, individualNote, { isPlaceholderNote: true });
const placeholderNote = { ...individualNote, isPlaceholderNote: true };
const state = { discussions: [placeholderNote] };
mutations.REMOVE_PLACEHOLDER_NOTES(state);
......@@ -298,7 +298,7 @@ describe('Notes Store mutations', () => {
describe('TOGGLE_DISCUSSION', () => {
it('should open a closed discussion', () => {
const discussion = Object.assign({}, discussionMock, { expanded: false });
const discussion = { ...discussionMock, expanded: false };
const state = {
discussions: [discussion],
......@@ -348,8 +348,8 @@ describe('Notes Store mutations', () => {
});
it('should open all closed discussions', () => {
const discussion1 = Object.assign({}, discussionMock, { id: 0, expanded: false });
const discussion2 = Object.assign({}, discussionMock, { id: 1, expanded: true });
const discussion1 = { ...discussionMock, id: 0, expanded: false };
const discussion2 = { ...discussionMock, id: 1, expanded: true };
const discussionIds = [discussion1.id, discussion2.id];
const state = { discussions: [discussion1, discussion2] };
......@@ -362,8 +362,8 @@ describe('Notes Store mutations', () => {
});
it('should close all opened discussions', () => {
const discussion1 = Object.assign({}, discussionMock, { id: 0, expanded: false });
const discussion2 = Object.assign({}, discussionMock, { id: 1, expanded: true });
const discussion1 = { ...discussionMock, id: 0, expanded: false };
const discussion2 = { ...discussionMock, id: 1, expanded: true };
const discussionIds = [discussion1.id, discussion2.id];
const state = { discussions: [discussion1, discussion2] };
......@@ -382,7 +382,7 @@ describe('Notes Store mutations', () => {
discussions: [individualNote],
};
const updated = Object.assign({}, individualNote.notes[0], { note: 'Foo' });
const updated = { ...individualNote.notes[0], note: 'Foo' };
mutations.UPDATE_NOTE(state, updated);
......
......@@ -26,7 +26,7 @@ describe('stage column component', () => {
beforeEach(() => {
const mockGroups = [];
for (let i = 0; i < 3; i += 1) {
const mockedJob = Object.assign({}, mockJob);
const mockedJob = { ...mockJob };
mockedJob.id += i;
mockGroups.push(mockedJob);
}
......
......@@ -601,7 +601,7 @@ describe('Pipelines', () => {
describe('updates results when a staged is clicked', () => {
beforeEach(() => {
const copyPipeline = Object.assign({}, pipelineWithStages);
const copyPipeline = { ...pipelineWithStages };
copyPipeline.id += 1;
mock
.onGet('twitter/flight/pipelines.json')
......
......@@ -169,7 +169,7 @@ describe('Pipelines Table Row', () => {
};
beforeEach(() => {
const withActions = Object.assign({}, pipeline);
const withActions = { ...pipeline };
withActions.details.scheduled_actions = [scheduledJobAction];
withActions.flags.cancelable = true;
withActions.flags.retryable = true;
......
......@@ -96,7 +96,7 @@ describe('Pipelines stage component', () => {
describe('update endpoint correctly', () => {
beforeEach(() => {
const copyStage = Object.assign({}, stageReply);
const copyStage = { ...stageReply };
copyStage.latest_statuses[0].name = 'this is the updated content';
mock.onGet('bar.json').reply(200, copyStage);
createComponent({
......
......@@ -7,7 +7,7 @@ describe('EE Pipeline store', () => {
beforeEach(() => {
store = new PipelineStore();
data = Object.assign({}, LinkedPipelines);
data = { ...LinkedPipelines };
store.storePipeline(data);
});
......
......@@ -20,7 +20,7 @@ describe('Mutations TestReports Store', () => {
describe('set endpoint', () => {
it('should set endpoint', () => {
const expectedState = Object.assign({}, mockState, { endpoint: 'foo' });
const expectedState = { ...mockState, endpoint: 'foo' };
mutations[types.SET_ENDPOINT](mockState, 'foo');
expect(mockState.endpoint).toEqual(expectedState.endpoint);
......@@ -47,14 +47,14 @@ describe('Mutations TestReports Store', () => {
describe('toggle loading', () => {
it('should set to true', () => {
const expectedState = Object.assign({}, mockState, { isLoading: true });
const expectedState = { ...mockState, isLoading: true };
mutations[types.TOGGLE_LOADING](mockState);
expect(mockState.isLoading).toEqual(expectedState.isLoading);
});
it('should toggle back to false', () => {
const expectedState = Object.assign({}, mockState, { isLoading: false });
const expectedState = { ...mockState, isLoading: false };
mockState.isLoading = true;
mutations[types.TOGGLE_LOADING](mockState);
......
......@@ -84,9 +84,7 @@ describe('Blob Embeddable', () => {
});
it('sets rich viewer correctly', () => {
const data = Object.assign({}, dataMock, {
activeViewerType: RichViewerMock.type,
});
const data = { ...dataMock, activeViewerType: RichViewerMock.type };
createComponent({}, data);
expect(wrapper.find(RichViewer).exists()).toBe(true);
});
......
......@@ -17,7 +17,7 @@ describe('Snippet header component', () => {
};
function createComponent({ props = snippet } = {}) {
const defaultProps = Object.assign({}, props);
const defaultProps = { ...props };
wrapper = shallowMount(SnippetTitle, {
propsData: {
......
......@@ -46,10 +46,11 @@ describe('Tracking', () => {
expect(snowplowSpy).not.toHaveBeenCalledWith('enableFormTracking');
expect(snowplowSpy).not.toHaveBeenCalledWith('enableLinkClickTracking');
window.snowplowOptions = Object.assign({}, window.snowplowOptions, {
window.snowplowOptions = {
...window.snowplowOptions,
formTracking: true,
linkClickTracking: true,
});
};
initUserTracking();
expect(snowplowSpy).toHaveBeenCalledWith('enableFormTracking');
......
......@@ -61,7 +61,7 @@ describe('Merge Request Collapsible Extension', () => {
describe('while loading', () => {
beforeEach(() => {
mountComponent(Object.assign({}, data, { isLoading: true }));
mountComponent({ ...data, isLoading: true });
});
it('renders the buttons disabled', () => {
......@@ -86,7 +86,7 @@ describe('Merge Request Collapsible Extension', () => {
describe('with error', () => {
beforeEach(() => {
mountComponent(Object.assign({}, data, { hasError: true }));
mountComponent({ ...data, hasError: true });
});
it('does not render the buttons', () => {
......
......@@ -13,7 +13,7 @@ describe('MrWidgetPipelineContainer', () => {
const factory = (props = {}) => {
wrapper = mount(MrWidgetPipelineContainer, {
propsData: {
mr: Object.assign({}, mockStore),
mr: { ...mockStore },
...props,
},
});
......
......@@ -91,9 +91,7 @@ describe('File row component', () => {
jest.spyOn(wrapper.vm, 'scrollIntoView');
wrapper.setProps({
file: Object.assign({}, wrapper.props('file'), {
active: true,
}),
file: { ...wrapper.props('file'), active: true },
});
return nextTick().then(() => {
......@@ -125,9 +123,7 @@ describe('File row component', () => {
it('matches the current route against encoded file URL', () => {
const fileName = 'with space';
const rowFile = Object.assign({}, file(fileName), {
url: `/${fileName}`,
});
const rowFile = { ...file(fileName), url: `/${fileName}` };
const routerPath = `/project/${escapeFileUrl(fileName)}`;
createComponent(
{
......
......@@ -36,9 +36,7 @@ describe('IssueMilestoneComponent', () => {
describe('isMilestoneStarted', () => {
it('should return `false` when milestoneStart prop is not defined', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
start_date: '',
}),
milestone: { ...mockMilestone, start_date: '' },
});
expect(wrapper.vm.isMilestoneStarted).toBe(false);
......@@ -46,9 +44,7 @@ describe('IssueMilestoneComponent', () => {
it('should return `true` when milestone start date is past current date', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
start_date: '1990-07-22',
}),
milestone: { ...mockMilestone, start_date: '1990-07-22' },
});
expect(wrapper.vm.isMilestoneStarted).toBe(true);
......@@ -58,9 +54,7 @@ describe('IssueMilestoneComponent', () => {
describe('isMilestonePastDue', () => {
it('should return `false` when milestoneDue prop is not defined', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
due_date: '',
}),
milestone: { ...mockMilestone, due_date: '' },
});
expect(wrapper.vm.isMilestonePastDue).toBe(false);
......@@ -68,9 +62,7 @@ describe('IssueMilestoneComponent', () => {
it('should return `true` when milestone due is past current date', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
due_date: '1990-07-22',
}),
milestone: { ...mockMilestone, due_date: '1990-07-22' },
});
expect(wrapper.vm.isMilestonePastDue).toBe(true);
......@@ -84,9 +76,7 @@ describe('IssueMilestoneComponent', () => {
it('returns string containing absolute milestone start date when due date is not present', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
due_date: '',
}),
milestone: { ...mockMilestone, due_date: '' },
});
expect(wrapper.vm.milestoneDatesAbsolute).toBe('(January 1, 2018)');
......@@ -94,10 +84,7 @@ describe('IssueMilestoneComponent', () => {
it('returns empty string when both milestone start and due dates are not present', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
start_date: '',
due_date: '',
}),
milestone: { ...mockMilestone, start_date: '', due_date: '' },
});
expect(wrapper.vm.milestoneDatesAbsolute).toBe('');
......@@ -107,9 +94,7 @@ describe('IssueMilestoneComponent', () => {
describe('milestoneDatesHuman', () => {
it('returns string containing milestone due date when date is yet to be due', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
due_date: `${new Date().getFullYear() + 10}-01-01`,
}),
milestone: { ...mockMilestone, due_date: `${new Date().getFullYear() + 10}-01-01` },
});
expect(wrapper.vm.milestoneDatesHuman).toContain('years remaining');
......@@ -117,10 +102,7 @@ describe('IssueMilestoneComponent', () => {
it('returns string containing milestone start date when date has already started and due date is not present', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
start_date: '1990-07-22',
due_date: '',
}),
milestone: { ...mockMilestone, start_date: '1990-07-22', due_date: '' },
});
expect(wrapper.vm.milestoneDatesHuman).toContain('Started');
......@@ -128,10 +110,11 @@ describe('IssueMilestoneComponent', () => {
it('returns string containing milestone start date when date is yet to start and due date is not present', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
milestone: {
...mockMilestone,
start_date: `${new Date().getFullYear() + 10}-01-01`,
due_date: '',
}),
},
});
expect(wrapper.vm.milestoneDatesHuman).toContain('Starts');
......@@ -139,10 +122,7 @@ describe('IssueMilestoneComponent', () => {
it('returns empty string when milestone start and due dates are not present', () => {
wrapper.setProps({
milestone: Object.assign({}, mockMilestone, {
start_date: '',
due_date: '',
}),
milestone: { ...mockMilestone, start_date: '', due_date: '' },
});
expect(wrapper.vm.milestoneDatesHuman).toBe('');
......
......@@ -8,11 +8,12 @@ import {
mockLabels,
} from '../../../../../javascripts/vue_shared/components/sidebar/labels_select/mock_data';
const componentConfig = Object.assign({}, mockConfig, {
const componentConfig = {
...mockConfig,
fieldName: 'label_id[]',
labels: mockLabels,
showExtraOptions: false,
});
};
const createComponent = (config = componentConfig) => {
const Component = Vue.extend(dropdownButtonComponent);
......@@ -34,7 +35,7 @@ describe('DropdownButtonComponent', () => {
describe('computed', () => {
describe('dropdownToggleText', () => {
it('returns text as `Label` when `labels` prop is empty array', () => {
const mockEmptyLabels = Object.assign({}, componentConfig, { labels: [] });
const mockEmptyLabels = { ...componentConfig, labels: [] };
const vmEmptyLabels = createComponent(mockEmptyLabels);
expect(vmEmptyLabels.dropdownToggleText).toBe('Label');
......@@ -42,9 +43,7 @@ describe('DropdownButtonComponent', () => {
});
it('returns first label name with remaining label count when `labels` prop has more than one item', () => {
const mockMoreLabels = Object.assign({}, componentConfig, {
labels: mockLabels.concat(mockLabels),
});
const mockMoreLabels = { ...componentConfig, labels: mockLabels.concat(mockLabels) };
const vmMoreLabels = createComponent(mockMoreLabels);
expect(vmMoreLabels.dropdownToggleText).toBe(
......@@ -54,9 +53,7 @@ describe('DropdownButtonComponent', () => {
});
it('returns first label name when `labels` prop has only one item present', () => {
const singleLabel = Object.assign({}, componentConfig, {
labels: [mockLabels[0]],
});
const singleLabel = { ...componentConfig, labels: [mockLabels[0]] };
const vmSingleLabel = createComponent(singleLabel);
expect(vmSingleLabel.dropdownToggleText).toBe(mockLabels[0].title);
......
......@@ -15,7 +15,7 @@ describe('LabelsSelect Actions', () => {
};
beforeEach(() => {
state = Object.assign({}, defaultState());
state = { ...defaultState() };
});
describe('setInitialState', () => {
......
......@@ -69,7 +69,7 @@ const defaults = {
};
function testGlEmojiElement(element, name, unicodeVersion, unicodeMoji, options = {}) {
const opts = Object.assign({}, defaults, options);
const opts = { ...defaults, ...options };
expect(element.tagName.toLowerCase()).toBe('gl-emoji');
expect(element.dataset.name).toBe(name);
expect(element.dataset.fallbackSrc.length).toBeGreaterThan(0);
......@@ -383,9 +383,7 @@ describe('gl_emoji', () => {
it('bomb(6.0) with 6.0 support', () => {
const emojiKey = 'bomb';
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
'6.0': true,
});
const unicodeSupportMap = { ...emptySupportMap, '6.0': true };
const isSupported = isEmojiUnicodeSupported(
unicodeSupportMap,
emojiFixtureMap[emojiKey].moji,
......@@ -409,9 +407,7 @@ describe('gl_emoji', () => {
it('bomb(6.0) without 6.0 but with 9.0 support', () => {
const emojiKey = 'bomb';
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
'9.0': true,
});
const unicodeSupportMap = { ...emptySupportMap, '9.0': true };
const isSupported = isEmojiUnicodeSupported(
unicodeSupportMap,
emojiFixtureMap[emojiKey].moji,
......@@ -423,7 +419,8 @@ describe('gl_emoji', () => {
it('construction_worker_tone5(8.0) without skin tone modifier support', () => {
const emojiKey = 'construction_worker_tone5';
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
const unicodeSupportMap = {
...emptySupportMap,
skinToneModifier: false,
'9.0': true,
'8.0': true,
......@@ -437,7 +434,7 @@ describe('gl_emoji', () => {
3.2: true,
'3.0': true,
1.1: true,
});
};
const isSupported = isEmojiUnicodeSupported(
unicodeSupportMap,
emojiFixtureMap[emojiKey].moji,
......@@ -449,13 +446,14 @@ describe('gl_emoji', () => {
it('use native keycap on >=57 chrome', () => {
const emojiKey = 'five';
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
const unicodeSupportMap = {
...emptySupportMap,
'3.0': true,
meta: {
isChrome: true,
chromeVersion: 57,
},
});
};
const isSupported = isEmojiUnicodeSupported(
unicodeSupportMap,
emojiFixtureMap[emojiKey].moji,
......@@ -467,13 +465,14 @@ describe('gl_emoji', () => {
it('fallback keycap on <57 chrome', () => {
const emojiKey = 'five';
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
const unicodeSupportMap = {
...emptySupportMap,
'3.0': true,
meta: {
isChrome: true,
chromeVersion: 50,
},
});
};
const isSupported = isEmojiUnicodeSupported(
unicodeSupportMap,
emojiFixtureMap[emojiKey].moji,
......
......@@ -44,19 +44,17 @@ describe('glDropdown', function describeDropdown() {
};
function initDropDown(hasRemote, isFilterable, extraOpts = {}) {
const options = Object.assign(
{
selectable: true,
filterable: isFilterable,
data: hasRemote ? remoteMock.bind({}, this.projectsData) : this.projectsData,
search: {
fields: ['name'],
},
text: project => project.name_with_namespace || project.name,
id: project => project.id,
const options = {
selectable: true,
filterable: isFilterable,
data: hasRemote ? remoteMock.bind({}, this.projectsData) : this.projectsData,
search: {
fields: ['name'],
},
extraOpts,
);
text: project => project.name_with_namespace || project.name,
id: project => project.id,
...extraOpts,
};
this.dropdownButtonElement = $(
'#js-project-dropdown',
this.dropdownContainerElement,
......
......@@ -10,11 +10,7 @@ describe('ImageBadge', () => {
};
it('should save actual property', () => {
const imageBadge = new ImageBadge(
Object.assign({}, options, {
actual: imageMeta,
}),
);
const imageBadge = new ImageBadge({ ...options, actual: imageMeta });
const { actual } = imageBadge;
......@@ -25,11 +21,7 @@ describe('ImageBadge', () => {
});
it('should save browser property', () => {
const imageBadge = new ImageBadge(
Object.assign({}, options, {
browser: imageMeta,
}),
);
const imageBadge = new ImageBadge({ ...options, browser: imageMeta });
const { browser } = imageBadge;
......@@ -83,11 +75,7 @@ describe('ImageBadge', () => {
});
it('should generate browser property', () => {
const imageBadge = new ImageBadge(
Object.assign({}, options, {
imageEl: document.createElement('img'),
}),
);
const imageBadge = new ImageBadge({ ...options, imageEl: document.createElement('img') });
expect(imageDiffHelper.resizeCoordinatesToImageElement).toHaveBeenCalled();
expect(imageBadge.browser).toEqual(true);
......
......@@ -66,7 +66,7 @@ describe('Commit block', () => {
describe('without merge request', () => {
it('does not render merge request', () => {
const copyProps = Object.assign({}, props);
const copyProps = { ...props };
delete copyProps.mergeRequest;
vm = mountComponent(Component, {
......
......@@ -20,7 +20,7 @@ describe('Sidebar details block', () => {
describe('when there is no retry path retry', () => {
it('should not render a retry button', () => {
const copy = Object.assign({}, job);
const copy = { ...job };
delete copy.retry_path;
store.dispatch('receiveJobSuccess', copy);
......@@ -43,10 +43,7 @@ describe('Sidebar details block', () => {
describe('with terminal path', () => {
it('renders terminal link', () => {
store.dispatch(
'receiveJobSuccess',
Object.assign({}, job, { terminal_path: 'job/43123/terminal' }),
);
store.dispatch('receiveJobSuccess', { ...job, terminal_path: 'job/43123/terminal' });
vm = mountComponentWithStore(SidebarComponent, {
store,
});
......
......@@ -40,7 +40,7 @@ describe('Test Issue body', () => {
beforeEach(() => {
vm = mountComponentWithStore(Component, {
store,
props: Object.assign({}, commonProps, { isNew: true }),
props: { ...commonProps, isNew: true },
});
});
......
......@@ -153,7 +153,7 @@ describe('MRWidgetHeader', () => {
beforeEach(() => {
vm = mountComponent(Component, {
mr: Object.assign({}, mrDefaultOptions),
mr: { ...mrDefaultOptions },
});
});
......@@ -176,7 +176,7 @@ describe('MRWidgetHeader', () => {
});
it('renders web ide button in disabled state with no href', () => {
const mr = Object.assign({}, mrDefaultOptions, { canPushToSourceBranch: false });
const mr = { ...mrDefaultOptions, canPushToSourceBranch: false };
vm = mountComponent(Component, { mr });
const link = vm.$el.querySelector('.js-web-ide');
......
......@@ -30,11 +30,7 @@ describe('DiffViewer', () => {
relative_url_root: '',
};
createComponent(
Object.assign({}, requiredProps, {
projectPath: '',
}),
);
createComponent({ ...requiredProps, projectPath: '' });
setTimeout(() => {
expect(vm.$el.querySelector('.deleted img').getAttribute('src')).toBe(
......@@ -50,13 +46,12 @@ describe('DiffViewer', () => {
});
it('renders fallback download diff display', done => {
createComponent(
Object.assign({}, requiredProps, {
diffViewerMode: 'added',
newPath: 'test.abc',
oldPath: 'testold.abc',
}),
);
createComponent({
...requiredProps,
diffViewerMode: 'added',
newPath: 'test.abc',
oldPath: 'testold.abc',
});
setTimeout(() => {
expect(vm.$el.querySelector('.deleted .file-info').textContent.trim()).toContain(
......@@ -77,28 +72,26 @@ describe('DiffViewer', () => {
});
it('renders renamed component', () => {
createComponent(
Object.assign({}, requiredProps, {
diffMode: 'renamed',
diffViewerMode: 'renamed',
newPath: 'test.abc',
oldPath: 'testold.abc',
}),
);
createComponent({
...requiredProps,
diffMode: 'renamed',
diffViewerMode: 'renamed',
newPath: 'test.abc',
oldPath: 'testold.abc',
});
expect(vm.$el.textContent).toContain('File moved');
});
it('renders mode changed component', () => {
createComponent(
Object.assign({}, requiredProps, {
diffMode: 'mode_changed',
newPath: 'test.abc',
oldPath: 'testold.abc',
aMode: '123',
bMode: '321',
}),
);
createComponent({
...requiredProps,
diffMode: 'mode_changed',
newPath: 'test.abc',
oldPath: 'testold.abc',
aMode: '123',
bMode: '321',
});
expect(vm.$el.textContent).toContain('File mode changed from 123 to 321');
});
......
......@@ -25,12 +25,7 @@ describe('toolbar', () => {
describe('user cannot attach file', () => {
beforeEach(() => {
vm = mountComponent(
Toolbar,
Object.assign({}, props, {
canAttachFile: false,
}),
);
vm = mountComponent(Toolbar, { ...props, canAttachFile: false });
});
it('should not render uploading-container', () => {
......
......@@ -5,18 +5,15 @@ import stackedProgressBarComponent from '~/vue_shared/components/stacked_progres
const createComponent = config => {
const Component = Vue.extend(stackedProgressBarComponent);
const defaultConfig = Object.assign(
{},
{
successLabel: 'Synced',
failureLabel: 'Failed',
neutralLabel: 'Out of sync',
successCount: 25,
failureCount: 10,
totalCount: 5000,
},
config,
);
const defaultConfig = {
successLabel: 'Synced',
failureLabel: 'Failed',
neutralLabel: 'Out of sync',
successCount: 25,
failureCount: 10,
totalCount: 5000,
...config,
};
return mountComponent(Component, defaultConfig);
};
......
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