Commit 19f22930 authored by Mike Greiling's avatar Mike Greiling

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

Use Object spread over Object.assign in ee/

See merge request gitlab-org/gitlab!31357
parents 0287d51d b709b696
......@@ -58,7 +58,8 @@ export default {
},
mounted() {
if (this.allowCustomOrdering) {
const options = Object.assign({}, sortableDefaultOptions(), {
const options = {
...sortableDefaultOptions(),
onUpdate: event => {
const el = event.item;
......@@ -70,7 +71,7 @@ export default {
this.$emit('reorderStage', { id, moveAfterId, moveBeforeId });
},
});
};
this.sortable = Sortable.create(this.$refs.list, options);
}
},
......
......@@ -7,7 +7,8 @@ export default () => {
const touchEnabled =
'ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch);
return Object.assign({}, sortableConfig, {
return {
...sortableConfig,
fallbackOnBody: false,
group: {
name: 'stages',
......@@ -22,5 +23,5 @@ export default () => {
onMove(e) {
return !e.related.classList.contains(NO_DRAG_CLASS);
},
});
};
};
......@@ -2,7 +2,7 @@ import axios from '~/lib/utils/axios_utils';
export default {
createNewDraft(endpoint, data) {
const postData = Object.assign({}, data, { draft_note: data.note });
const postData = { ...data, draft_note: data.note };
delete postData.note;
return axios.post(endpoint, postData);
......
......@@ -25,12 +25,10 @@ export default class EnvironmentsStore extends CeEnvironmentsStore {
const environments = this.state.environments.slice();
this.state.environments = environments.map(env => {
let updated = Object.assign({}, env);
let updated = { ...env };
if (env.id === environmentID) {
updated = Object.assign({}, updated, {
isDeployBoardVisible: !env.isDeployBoardVisible,
});
updated = { ...updated, isDeployBoardVisible: !env.isDeployBoardVisible };
}
return updated;
});
......
......@@ -8,7 +8,8 @@
export const setDeployBoard = (oldEnvironmentState, environment) => {
let parsedEnvironment = environment;
if (environment.size === 1 && environment.rollout_status) {
parsedEnvironment = Object.assign({}, environment, {
parsedEnvironment = {
...environment,
hasDeployBoard: true,
isDeployBoardVisible:
oldEnvironmentState.isDeployBoardVisible === false
......@@ -19,7 +20,7 @@ export const setDeployBoard = (oldEnvironmentState, environment) => {
isLoadingDeployBoard: environment.rollout_status.status === 'loading',
isEmptyDeployBoard: environment.rollout_status.status === 'not_found',
hasLegacyAppLabel: environment.rollout_status.has_legacy_app_label,
});
};
}
return parsedEnvironment;
};
......@@ -96,7 +96,7 @@ export default class AccessDropdown {
}
const persistedItems = itemsToPreselect.map(item => {
const persistedItem = Object.assign({}, item);
const persistedItem = { ...item };
persistedItem.persisted = true;
return persistedItem;
});
......@@ -361,7 +361,7 @@ export default class AccessDropdown {
usersResponse.forEach(response => {
// Add is it has not been added
if (map.indexOf(LEVEL_TYPES.USER + response.id) === -1) {
const user = Object.assign({}, response);
const user = { ...response };
user.type = LEVEL_TYPES.USER;
users.push(user);
}
......
......@@ -55,13 +55,11 @@ export default {
},
mounted() {
if (this.canReorder) {
this.sortable = Sortable.create(
this.$refs.list,
Object.assign({}, sortableConfig, {
this.sortable = Sortable.create(this.$refs.list, {
...sortableConfig,
onStart: this.addDraggingCursor,
onEnd: this.reordered,
}),
);
});
}
},
methods: {
......
......@@ -48,10 +48,7 @@ export const applySorts = array => array.sort(sortChildren).sort(sortByState);
* flags and properties to use while rendering tree.
* @param {Object} item
*/
export const formatChildItem = item =>
Object.assign({}, item, {
pathIdSeparator: PathIdSeparator[item.type],
});
export const formatChildItem = item => ({ ...item, pathIdSeparator: PathIdSeparator[item.type] });
/**
* Returns formatted array of Epics that doesn't contain
......
......@@ -45,7 +45,7 @@ export default {
return this.isOpen ? 'angle-down' : 'angle-right';
},
statistics() {
const statisticsCopy = Object.assign({}, this.project.statistics);
const statisticsCopy = { ...this.project.statistics };
delete statisticsCopy.storageSize;
// eslint-disable-next-line no-underscore-dangle
delete statisticsCopy.__typename;
......
......@@ -19,9 +19,12 @@ export const setSelectedEpic = ({ commit }, selectedEpic) =>
export const requestEpics = ({ commit }) => commit(types.REQUEST_EPICS);
export const receiveEpicsSuccess = ({ commit }, data) => {
const epics = data.map(rawEpic =>
convertObjectPropsToCamelCase(Object.assign({}, rawEpic, { url: rawEpic.web_edit_url }), {
convertObjectPropsToCamelCase(
{ ...rawEpic, url: rawEpic.web_edit_url },
{
dropKeys: ['web_edit_url'],
}),
},
),
);
commit(types.RECEIVE_EPICS_SUCCESS, { epics });
......
const downloadPatchHelper = (patch, opts = {}) => {
const mergedOpts = Object.assign(
{
const mergedOpts = {
isEncoded: true,
},
opts,
);
...opts,
};
const url = `data:text/plain;base64,${mergedOpts.isEncoded ? patch : btoa(patch)}`;
const link = document.createElement('a');
......
......@@ -31,7 +31,7 @@ export default {
const index = this.notes.indexOf(comment);
if (index > -1) {
this.notes.splice(index, 1, Object.assign({}, comment, data));
this.notes.splice(index, 1, { ...comment, ...data });
}
},
removeComment(comment) {
......
......@@ -33,7 +33,7 @@ describe('Api', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
originalGon = window.gon;
window.gon = Object.assign({}, dummyGon);
window.gon = { ...dummyGon };
});
afterEach(() => {
......
......@@ -13,10 +13,12 @@ export const mockEpicMeta = {
};
export const mockEpicData = convertObjectPropsToCamelCase(
Object.assign({}, getJSONFixture('epic/mock_data.json'), initial, {
{
...getJSONFixture('epic/mock_data.json'),
...initial,
endpoint: TEST_HOST,
sidebarCollapsed: false,
}),
},
{ deep: true },
);
......
......@@ -14,7 +14,7 @@ describe('Epic Store Actions', () => {
let state;
beforeEach(() => {
state = Object.assign({}, defaultState());
state = { ...defaultState() };
});
describe('setEpicMeta', () => {
......
......@@ -54,13 +54,13 @@ describe('GeoNodeActionsComponent', () => {
describe('nodeToggleLabel', () => {
it('returns label for toggle button for a node', () => {
let mockNode = Object.assign({}, mockNodes[1]);
let mockNode = { ...mockNodes[1] };
let vmX = createComponent(mockNode);
expect(vmX.nodeToggleLabel).toBe('Pause replication');
vmX.$destroy();
mockNode = Object.assign({}, mockNodes[1], { enabled: false });
mockNode = { ...mockNodes[1], enabled: false };
vmX = createComponent(mockNode);
expect(vmX.nodeToggleLabel).toBe('Resume replication');
......
......@@ -5,8 +5,8 @@ import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNode, mockNodeDetails } from '../mock_data';
const createComponent = ({
node = Object.assign({}, mockNode),
nodeDetails = Object.assign({}, mockNodeDetails),
node = { ...mockNode },
nodeDetails = { ...mockNodeDetails },
nodeDetailsLoading = false,
nodeDetailsFailed = false,
}) => {
......
......@@ -50,10 +50,7 @@ describe('GeoNodeItemComponent', () => {
describe('handleNodeDetails', () => {
describe('with matching ID', () => {
beforeEach(() => {
const mockNodeSecondary = Object.assign({}, mockNode, {
id: mockNodeDetails.id,
primary: false,
});
const mockNodeSecondary = { ...mockNode, id: mockNodeDetails.id, primary: false };
createComponent({ node: mockNodeSecondary });
});
......
......@@ -7,8 +7,8 @@ import { mockNode, mockNodeDetails } from '../../mock_data';
const MOCK_VERSION_TEXT = `${mockNodeDetails.version} (${mockNodeDetails.revision})`;
const createComponent = ({
node = Object.assign({}, mockNode),
nodeDetails = Object.assign({}, mockNodeDetails),
node = { ...mockNode },
nodeDetails = { ...mockNodeDetails },
nodeActionsAllowed = true,
nodeEditAllowed = true,
nodeRemovalAllowed = true,
......
......@@ -6,8 +6,8 @@ import { mockNode, mockNodeDetails } from '../../mock_data';
import { numberToHumanSize } from '~/lib/utils/number_utils';
const createComponent = (
node = Object.assign({}, mockNode),
nodeDetails = Object.assign({}, mockNodeDetails),
node = { ...mockNode },
nodeDetails = { ...mockNodeDetails },
nodeTypePrimary = false,
) => {
const Component = Vue.extend(NodeDetailsSectionOtherComponent);
......
......@@ -48,7 +48,7 @@ describe('Insights mutations', () => {
it('sets configData state to incoming data on success', () => {
mutations[types.RECEIVE_CONFIG_SUCCESS](state, configData);
const expected = Object.assign({}, configData);
const expected = { ...configData };
delete expected.invalid;
expect(state.configData).toEqual(expected);
......
......@@ -24,8 +24,8 @@ describe('LicenseCardBody', () => {
function createComponent(props = {}) {
let propsData = props;
propsData.license = Object.assign({}, defaultProps.license, props.license || {});
propsData = Object.assign({}, defaultProps, props);
propsData.license = { ...defaultProps.license, ...(props.license || {}) };
propsData = { ...defaultProps, ...props };
wrapper = shallowMount(LicenseCardBody, {
propsData,
......
......@@ -23,14 +23,14 @@ describe('LicenseCard', () => {
localVue.use(Vuex);
function createStore(newState) {
const state = Object.assign({}, defaultState, newState);
const state = { ...defaultState, ...newState };
actions = { fetchDeleteLicense: jest.fn() };
return new Vuex.Store({ state, actions });
}
function createComponent(state, props) {
const propsData = Object.assign({}, defaultProps, props);
const propsData = { ...defaultProps, ...props };
wrapper = shallowMount(LicenseCard, {
store: createStore(state),
......
......@@ -9,7 +9,7 @@ describe('Cell', () => {
};
function createComponent(props, slots) {
const propsData = Object.assign({}, defaultProps, props);
const propsData = { ...defaultProps, ...props };
wrapper = shallowMount(Cell, {
propsData,
......
......@@ -9,7 +9,7 @@ describe('DateCell', () => {
};
function createComponent(props) {
const propsData = Object.assign({}, defaultProps, props);
const propsData = { ...defaultProps, ...props };
wrapper = shallowMount(DateCell, {
propsData,
......
......@@ -10,7 +10,7 @@ describe('InfoCell', () => {
};
function createComponent(props, slots) {
const propsData = Object.assign({}, defaultProps, props);
const propsData = { ...defaultProps, ...props };
wrapper = shallowMount(InfoCell, {
propsData,
......
......@@ -20,11 +20,12 @@ import { mockParentItem, mockInitialConfig, mockQueryResponse, mockIssue1 } from
const localVue = createLocalVue();
localVue.use(Vuex);
const mockItem = Object.assign({}, mockIssue1, {
const mockItem = {
...mockIssue1,
type: ChildType.Issue,
pathIdSeparator: PathIdSeparator.Issue,
assignees: epicUtils.extractIssueAssignees(mockIssue1.assignees),
});
};
const createComponent = (parentItem = mockParentItem, item = mockItem) => {
const store = createDefaultStore();
......@@ -92,10 +93,7 @@ describe('RelatedItemsTree', () => {
it('returns value of `item.path`', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
path: mockPath,
webPath: undefined,
}),
item: { ...mockItem, path: mockPath, webPath: undefined },
});
return wrapper.vm.$nextTick(() => {
......@@ -105,10 +103,7 @@ describe('RelatedItemsTree', () => {
it('returns value of `item.webPath` when `item.path` is undefined', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
path: undefined,
webPath: mockPath,
}),
item: { ...mockItem, path: undefined, webPath: mockPath },
});
return wrapper.vm.$nextTick(() => {
......@@ -120,9 +115,7 @@ describe('RelatedItemsTree', () => {
describe('isOpen', () => {
it('returns true when `item.state` value is `opened`', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
state: ChildState.Open,
}),
item: { ...mockItem, state: ChildState.Open },
});
return wrapper.vm.$nextTick(() => {
......@@ -134,9 +127,7 @@ describe('RelatedItemsTree', () => {
describe('isClosed', () => {
it('returns true when `item.state` value is `closed`', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
state: ChildState.Closed,
}),
item: { ...mockItem, state: ChildState.Closed },
});
return wrapper.vm.$nextTick(() => {
......@@ -160,9 +151,7 @@ describe('RelatedItemsTree', () => {
describe('stateText', () => {
it('returns string `Opened` when `item.state` value is `opened`', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
state: ChildState.Open,
}),
item: { ...mockItem, state: ChildState.Open },
});
return wrapper.vm.$nextTick(() => {
......@@ -172,9 +161,7 @@ describe('RelatedItemsTree', () => {
it('returns string `Closed` when `item.state` value is `closed`', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
state: ChildState.Closed,
}),
item: { ...mockItem, state: ChildState.Closed },
});
return wrapper.vm.$nextTick(() => {
......@@ -186,9 +173,7 @@ describe('RelatedItemsTree', () => {
describe('stateIconName', () => {
it('returns string `issues` when `item.type` value is `issue`', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
type: ChildType.Issue,
}),
item: { ...mockItem, type: ChildType.Issue },
});
return wrapper.vm.$nextTick(() => {
......@@ -208,9 +193,7 @@ describe('RelatedItemsTree', () => {
describe('stateIconClass', () => {
it('returns string `issue-token-state-icon-open` when `item.state` value is `opened`', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
state: ChildState.Open,
}),
item: { ...mockItem, state: ChildState.Open },
});
return wrapper.vm.$nextTick(() => {
......@@ -220,9 +203,7 @@ describe('RelatedItemsTree', () => {
it('returns string `issue-token-state-icon-closed` when `item.state` value is `closed`', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
state: ChildState.Closed,
}),
item: { ...mockItem, state: ChildState.Closed },
});
return wrapper.vm.$nextTick(() => {
......@@ -250,9 +231,7 @@ describe('RelatedItemsTree', () => {
it('returns `null` when `itemWebPath` is empty', () => {
wrapper.setProps({
item: Object.assign({}, mockItem, {
webPath: '',
}),
item: { ...mockItem, webPath: '' },
});
return wrapper.vm.$nextTick(() => {
......
......@@ -14,11 +14,12 @@ import { mockParentItem, mockQueryResponse, mockIssue1 } from '../mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
const mockItem = Object.assign({}, mockIssue1, {
const mockItem = {
...mockIssue1,
type: ChildType.Issue,
pathIdSeparator: PathIdSeparator.Issue,
assignees: epicUtils.extractIssueAssignees(mockIssue1.assignees),
});
};
const createComponent = (parentItem = mockParentItem, item = mockItem) => {
const store = createDefaultStore();
......@@ -68,7 +69,7 @@ describe('RelatedItemsTree', () => {
it('returns title for modal when item.type is `Epic`', () => {
wrapper.vm.$store.dispatch('setRemoveItemModalProps', {
parentItem: mockParentItem,
item: Object.assign({}, mockItem, { type: ChildType.Epic }),
item: { ...mockItem, type: ChildType.Epic },
});
return wrapper.vm.$nextTick(() => {
......@@ -92,7 +93,7 @@ describe('RelatedItemsTree', () => {
it('returns body text for modal when item.type is `Epic`', () => {
wrapper.vm.$store.dispatch('setRemoveItemModalProps', {
parentItem: mockParentItem,
item: Object.assign({}, mockItem, { type: ChildType.Epic }),
item: { ...mockItem, type: ChildType.Epic },
});
return wrapper.vm.$nextTick(() => {
......
......@@ -15,10 +15,7 @@ import Icon from '~/vue_shared/components/icon.vue';
import { mockParentItem, mockQueryResponse, mockEpic1 } from '../mock_data';
const mockItem = Object.assign({}, mockEpic1, {
type: ChildType.Epic,
pathIdSeparator: PathIdSeparator.Epic,
});
const mockItem = { ...mockEpic1, type: ChildType.Epic, pathIdSeparator: PathIdSeparator.Epic };
const localVue = createLocalVue();
localVue.use(Vuex);
......
......@@ -101,17 +101,9 @@ describe('RelatedItemTree', () => {
});
describe('updateChildrenCount', () => {
const mockEpicsWithType = mockEpics.map(item =>
Object.assign({}, item, {
type: ChildType.Epic,
}),
);
const mockEpicsWithType = mockEpics.map(item => ({ ...item, type: ChildType.Epic }));
const mockIssuesWithType = mockIssues.map(item =>
Object.assign({}, item, {
type: ChildType.Issue,
}),
);
const mockIssuesWithType = mockIssues.map(item => ({ ...item, type: ChildType.Issue }));
it('should update openedEpics, by incrementing it', () => {
testAction(
......@@ -681,10 +673,7 @@ describe('RelatedItemTree', () => {
let mock;
const data = {
parentItem: mockParentItem,
item: Object.assign({}, mockParentItem, {
iid: 2,
relationPath: '/foo/bar',
}),
item: { ...mockParentItem, iid: 2, relationPath: '/foo/bar' },
};
beforeEach(() => {
......@@ -837,12 +826,11 @@ describe('RelatedItemTree', () => {
state.issuableType = issuableTypesMap.EPIC;
state.isEpic = true;
const mockEpicsWithoutPerm = mockEpics.map(item =>
Object.assign({}, item, {
const mockEpicsWithoutPerm = mockEpics.map(item => ({
...item,
pathIdSeparator: PathIdSeparator.Epic,
userPermissions: { adminEpic: undefined },
}),
);
}));
testAction(
actions.receiveAddItemSuccess,
......@@ -996,11 +984,12 @@ describe('RelatedItemTree', () => {
describe('receiveCreateItemSuccess', () => {
it('should set `state.itemCreateInProgress` to false', () => {
const createdEpic = Object.assign({}, mockEpics[0], {
const createdEpic = {
...mockEpics[0],
id: `gid://gitlab/Epic/${mockEpics[0].id}`,
reference: `${mockEpics[0].group.fullPath}${mockEpics[0].reference}`,
pathIdSeparator: PathIdSeparator.Epic,
});
};
state.parentItem = {
fullPath: createdEpic.group.fullPath,
};
......@@ -1090,11 +1079,7 @@ describe('RelatedItemTree', () => {
{
type: 'receiveCreateItemSuccess',
payload: {
rawItem: Object.assign({}, mockEpic1, {
path: '',
state: ChildState.Open,
created_at: '',
}),
rawItem: { ...mockEpic1, path: '', state: ChildState.Open, created_at: '' },
},
},
],
......
......@@ -72,10 +72,7 @@ describe('EpicItemComponent', () => {
it('returns Epic.originalStartDate when start date is out of range', () => {
const mockStartDate = new Date(2018, 0, 1);
const epic = Object.assign({}, mockEpic, {
startDateOutOfRange: true,
originalStartDate: mockStartDate,
});
const epic = { ...mockEpic, startDateOutOfRange: true, originalStartDate: mockStartDate };
wrapper = createComponent({ epic });
expect(wrapper.vm.startDate).toBe(mockStartDate);
......@@ -89,10 +86,7 @@ describe('EpicItemComponent', () => {
it('returns Epic.originalEndDate when end date is out of range', () => {
const mockEndDate = new Date(2018, 0, 1);
const epic = Object.assign({}, mockEpic, {
endDateOutOfRange: true,
originalEndDate: mockEndDate,
});
const epic = { ...mockEpic, endDateOutOfRange: true, originalEndDate: mockEndDate };
wrapper = createComponent({ epic });
expect(wrapper.vm.endDate).toBe(mockEndDate);
......@@ -105,28 +99,21 @@ describe('EpicItemComponent', () => {
});
it('returns timeframe string correctly when only start date is defined', () => {
const epic = Object.assign({}, mockEpic, {
endDateUndefined: true,
});
const epic = { ...mockEpic, endDateUndefined: true };
wrapper = createComponent({ epic });
expect(wrapper.vm.timeframeString(epic)).toBe('Jul 10, 2017 – No end date');
});
it('returns timeframe string correctly when only end date is defined', () => {
const epic = Object.assign({}, mockEpic, {
startDateUndefined: true,
});
const epic = { ...mockEpic, startDateUndefined: true };
wrapper = createComponent({ epic });
expect(wrapper.vm.timeframeString(epic)).toBe('No start date – Jun 2, 2018');
});
it('returns timeframe string with hidden year for start date when both start and end dates are from same year', () => {
const epic = Object.assign({}, mockEpic, {
startDate: new Date(2018, 0, 1),
endDate: new Date(2018, 3, 1),
});
const epic = { ...mockEpic, startDate: new Date(2018, 0, 1), endDate: new Date(2018, 3, 1) };
wrapper = createComponent({ epic });
expect(wrapper.vm.timeframeString(epic)).toBe('Jan 1 – Apr 1, 2018');
......
......@@ -75,10 +75,11 @@ describe('MilestoneItemComponent', () => {
it('returns Milestone.originalStartDate when start date is out of range', () => {
const mockStartDate = new Date(2018, 0, 1);
const mockMilestoneItem = Object.assign({}, mockMilestone2, {
const mockMilestoneItem = {
...mockMilestone2,
startDateOutOfRange: true,
originalStartDate: mockStartDate,
});
};
wrapper = createComponent({ milestone: mockMilestoneItem });
expect(wrapper.vm.startDate).toBe(mockStartDate);
......@@ -94,10 +95,11 @@ describe('MilestoneItemComponent', () => {
it('returns Milestone.originalEndDate when end date is out of range', () => {
const mockEndDate = new Date(2018, 0, 1);
const mockMilestoneItem = Object.assign({}, mockMilestone2, {
const mockMilestoneItem = {
...mockMilestone2,
endDateOutOfRange: true,
originalEndDate: mockEndDate,
});
};
wrapper = createComponent({ milestone: mockMilestoneItem });
expect(wrapper.vm.endDate).toBe(mockEndDate);
......@@ -112,28 +114,25 @@ describe('MilestoneItemComponent', () => {
});
it('returns timeframe string correctly when only start date is defined', () => {
const mockMilestoneItem = Object.assign({}, mockMilestone2, {
endDateUndefined: true,
});
const mockMilestoneItem = { ...mockMilestone2, endDateUndefined: true };
wrapper = createComponent({ milestone: mockMilestoneItem });
expect(wrapper.vm.timeframeString(mockMilestoneItem)).toBe('Nov 10, 2017 – No end date');
});
it('returns timeframe string correctly when only end date is defined', () => {
const mockMilestoneItem = Object.assign({}, mockMilestone2, {
startDateUndefined: true,
});
const mockMilestoneItem = { ...mockMilestone2, startDateUndefined: true };
wrapper = createComponent({ milestone: mockMilestoneItem });
expect(wrapper.vm.timeframeString(mockMilestoneItem)).toBe('No start date – Jul 2, 2018');
});
it('returns timeframe string with hidden year for start date when both start and end dates are from same year', () => {
const mockMilestoneItem = Object.assign({}, mockMilestone2, {
const mockMilestoneItem = {
...mockMilestone2,
startDate: new Date(2018, 0, 1),
endDate: new Date(2018, 3, 1),
});
};
wrapper = createComponent({ milestone: mockMilestoneItem });
expect(wrapper.vm.timeframeString(mockMilestoneItem)).toBe('Jan 1 – Apr 1, 2018');
......
......@@ -37,7 +37,7 @@ describe('MonthsPresetMixin', () => {
describe('hasStartDateForMonth', () => {
it('returns true when Epic.startDate falls within timeframeItem', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDate: mockTimeframeMonths[1] }),
epic: { ...mockEpic, startDate: mockTimeframeMonths[1] },
timeframeItem: mockTimeframeMonths[1],
});
......@@ -46,7 +46,7 @@ describe('MonthsPresetMixin', () => {
it('returns false when Epic.startDate does not fall within timeframeItem', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDate: mockTimeframeMonths[0] }),
epic: { ...mockEpic, startDate: mockTimeframeMonths[0] },
timeframeItem: mockTimeframeMonths[1],
});
......@@ -65,9 +65,7 @@ describe('MonthsPresetMixin', () => {
const epicEndDate = new Date(2018, 0, 26); // Jan 26, 2018
vm = createComponent({
epic: Object.assign({}, mockEpic, {
endDate: epicEndDate,
}),
epic: { ...mockEpic, endDate: epicEndDate },
});
expect(vm.isTimeframeUnderEndDateForMonth(timeframeItem)).toBe(true);
......@@ -77,9 +75,7 @@ describe('MonthsPresetMixin', () => {
const epicEndDate = new Date(2018, 1, 26); // Feb 26, 2018
vm = createComponent({
epic: Object.assign({}, mockEpic, {
endDate: epicEndDate,
}),
epic: { ...mockEpic, endDate: epicEndDate },
});
expect(vm.isTimeframeUnderEndDateForMonth(timeframeItem)).toBe(false);
......@@ -99,7 +95,7 @@ describe('MonthsPresetMixin', () => {
describe('getTimelineBarStartOffsetForMonths', () => {
it('returns empty string when Epic startDate is out of range', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDateOutOfRange: true }),
epic: { ...mockEpic, startDateOutOfRange: true },
});
expect(vm.getTimelineBarStartOffsetForMonths(vm.epic)).toBe('');
......@@ -107,10 +103,7 @@ describe('MonthsPresetMixin', () => {
it('returns empty string when Epic startDate is undefined and endDate is out of range', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDateUndefined: true,
endDateOutOfRange: true,
}),
epic: { ...mockEpic, startDateUndefined: true, endDateOutOfRange: true },
});
expect(vm.getTimelineBarStartOffsetForMonths(vm.epic)).toBe('');
......@@ -118,9 +111,7 @@ describe('MonthsPresetMixin', () => {
it('return `left: 0;` when Epic startDate is first day of the month', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDate: new Date(2018, 0, 1),
}),
epic: { ...mockEpic, startDate: new Date(2018, 0, 1) },
});
expect(vm.getTimelineBarStartOffsetForMonths(vm.epic)).toBe('left: 0;');
......@@ -128,9 +119,7 @@ describe('MonthsPresetMixin', () => {
it('returns proportional `left` value based on Epic startDate and days in the month', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDate: new Date(2018, 0, 15),
}),
epic: { ...mockEpic, startDate: new Date(2018, 0, 15) },
});
expect(vm.getTimelineBarStartOffsetForMonths(vm.epic)).toContain('left: 50%');
......@@ -141,10 +130,11 @@ describe('MonthsPresetMixin', () => {
it('returns calculated width value based on Epic.startDate and Epic.endDate', () => {
vm = createComponent({
timeframeItem: mockTimeframeMonths[0],
epic: Object.assign({}, mockEpic, {
epic: {
...mockEpic,
startDate: new Date(2017, 11, 15), // Dec 15, 2017
endDate: new Date(2018, 1, 15), // Feb 15, 2017
}),
},
});
expect(Math.floor(vm.getTimelineBarWidthForMonths())).toBe(546);
......
......@@ -37,7 +37,7 @@ describe('QuartersPresetMixin', () => {
describe('hasStartDateForQuarter', () => {
it('returns true when Epic.startDate falls within timeframeItem', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDate: mockTimeframeQuarters[1].range[0] }),
epic: { ...mockEpic, startDate: mockTimeframeQuarters[1].range[0] },
timeframeItem: mockTimeframeQuarters[1],
});
......@@ -46,7 +46,7 @@ describe('QuartersPresetMixin', () => {
it('returns false when Epic.startDate does not fall within timeframeItem', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDate: mockTimeframeQuarters[0].range[0] }),
epic: { ...mockEpic, startDate: mockTimeframeQuarters[0].range[0] },
timeframeItem: mockTimeframeQuarters[1],
});
......@@ -65,9 +65,7 @@ describe('QuartersPresetMixin', () => {
const epicEndDate = mockTimeframeQuarters[1].range[2];
vm = createComponent({
epic: Object.assign({}, mockEpic, {
endDate: epicEndDate,
}),
epic: { ...mockEpic, endDate: epicEndDate },
});
expect(vm.isTimeframeUnderEndDateForQuarter(timeframeItem)).toBe(true);
......@@ -77,9 +75,7 @@ describe('QuartersPresetMixin', () => {
const epicEndDate = mockTimeframeQuarters[2].range[1];
vm = createComponent({
epic: Object.assign({}, mockEpic, {
endDate: epicEndDate,
}),
epic: { ...mockEpic, endDate: epicEndDate },
});
expect(vm.isTimeframeUnderEndDateForQuarter(timeframeItem)).toBe(false);
......@@ -99,7 +95,7 @@ describe('QuartersPresetMixin', () => {
describe('getTimelineBarStartOffsetForQuarters', () => {
it('returns empty string when Epic startDate is out of range', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDateOutOfRange: true }),
epic: { ...mockEpic, startDateOutOfRange: true },
});
expect(vm.getTimelineBarStartOffsetForQuarters(vm.epic)).toBe('');
......@@ -107,10 +103,7 @@ describe('QuartersPresetMixin', () => {
it('returns empty string when Epic startDate is undefined and endDate is out of range', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDateUndefined: true,
endDateOutOfRange: true,
}),
epic: { ...mockEpic, startDateUndefined: true, endDateOutOfRange: true },
});
expect(vm.getTimelineBarStartOffsetForQuarters(vm.epic)).toBe('');
......@@ -118,9 +111,7 @@ describe('QuartersPresetMixin', () => {
it('return `left: 0;` when Epic startDate is first day of the quarter', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDate: mockTimeframeQuarters[0].range[0],
}),
epic: { ...mockEpic, startDate: mockTimeframeQuarters[0].range[0] },
});
expect(vm.getTimelineBarStartOffsetForQuarters(vm.epic)).toBe('left: 0;');
......@@ -128,9 +119,7 @@ describe('QuartersPresetMixin', () => {
it('returns proportional `left` value based on Epic startDate and days in the quarter', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDate: mockTimeframeQuarters[0].range[1],
}),
epic: { ...mockEpic, startDate: mockTimeframeQuarters[0].range[1] },
});
expect(vm.getTimelineBarStartOffsetForQuarters(vm.epic)).toContain('left: 34');
......@@ -141,10 +130,11 @@ describe('QuartersPresetMixin', () => {
it('returns calculated width value based on Epic.startDate and Epic.endDate', () => {
vm = createComponent({
timeframeItem: mockTimeframeQuarters[0],
epic: Object.assign({}, mockEpic, {
epic: {
...mockEpic,
startDate: mockTimeframeQuarters[0].range[1],
endDate: mockTimeframeQuarters[1].range[1],
}),
},
});
expect(Math.floor(vm.getTimelineBarWidthForQuarters(vm.epic))).toBe(180);
......
......@@ -37,7 +37,7 @@ describe('WeeksPresetMixin', () => {
describe('hasStartDateForWeek', () => {
it('returns true when Epic.startDate falls within timeframeItem', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDate: mockTimeframeWeeks[1] }),
epic: { ...mockEpic, startDate: mockTimeframeWeeks[1] },
timeframeItem: mockTimeframeWeeks[1],
});
......@@ -46,7 +46,7 @@ describe('WeeksPresetMixin', () => {
it('returns false when Epic.startDate does not fall within timeframeItem', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDate: mockTimeframeWeeks[0] }),
epic: { ...mockEpic, startDate: mockTimeframeWeeks[0] },
timeframeItem: mockTimeframeWeeks[1],
});
......@@ -76,9 +76,7 @@ describe('WeeksPresetMixin', () => {
const epicEndDate = new Date(2018, 0, 3); // Jan 3, 2018
vm = createComponent({
epic: Object.assign({}, mockEpic, {
endDate: epicEndDate,
}),
epic: { ...mockEpic, endDate: epicEndDate },
});
expect(vm.isTimeframeUnderEndDateForWeek(timeframeItem)).toBe(true);
......@@ -88,9 +86,7 @@ describe('WeeksPresetMixin', () => {
const epicEndDate = new Date(2018, 0, 15); // Jan 15, 2018
vm = createComponent({
epic: Object.assign({}, mockEpic, {
endDate: epicEndDate,
}),
epic: { ...mockEpic, endDate: epicEndDate },
});
expect(vm.isTimeframeUnderEndDateForWeek(timeframeItem)).toBe(false);
......@@ -110,7 +106,7 @@ describe('WeeksPresetMixin', () => {
describe('getTimelineBarStartOffsetForWeeks', () => {
it('returns empty string when Epic startDate is out of range', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, { startDateOutOfRange: true }),
epic: { ...mockEpic, startDateOutOfRange: true },
});
expect(vm.getTimelineBarStartOffsetForWeeks(vm.epic)).toBe('');
......@@ -118,10 +114,7 @@ describe('WeeksPresetMixin', () => {
it('returns empty string when Epic startDate is undefined and endDate is out of range', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDateUndefined: true,
endDateOutOfRange: true,
}),
epic: { ...mockEpic, startDateUndefined: true, endDateOutOfRange: true },
});
expect(vm.getTimelineBarStartOffsetForWeeks(vm.epic)).toBe('');
......@@ -129,9 +122,7 @@ describe('WeeksPresetMixin', () => {
it('return `left: 0;` when Epic startDate is first day of the week', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDate: mockTimeframeWeeks[0],
}),
epic: { ...mockEpic, startDate: mockTimeframeWeeks[0] },
});
expect(vm.getTimelineBarStartOffsetForWeeks(vm.epic)).toBe('left: 0;');
......@@ -139,9 +130,7 @@ describe('WeeksPresetMixin', () => {
it('returns proportional `left` value based on Epic startDate and days in the week', () => {
vm = createComponent({
epic: Object.assign({}, mockEpic, {
startDate: new Date(2018, 0, 15),
}),
epic: { ...mockEpic, startDate: new Date(2018, 0, 15) },
});
expect(vm.getTimelineBarStartOffsetForWeeks(vm.epic)).toContain('left: 38');
......@@ -152,10 +141,11 @@ describe('WeeksPresetMixin', () => {
it('returns calculated width value based on Epic.startDate and Epic.endDate', () => {
vm = createComponent({
timeframeItem: mockTimeframeWeeks[0],
epic: Object.assign({}, mockEpic, {
epic: {
...mockEpic,
startDate: new Date(2018, 0, 1), // Jan 1, 2018
endDate: new Date(2018, 1, 2), // Feb 2, 2018
}),
},
});
expect(Math.floor(vm.getTimelineBarWidthForWeeks())).toBe(1208);
......
......@@ -40,7 +40,8 @@ describe('Roadmap Vuex Actions', () => {
let state;
beforeEach(() => {
state = Object.assign({}, defaultState(), {
state = {
...defaultState(),
groupId: mockGroupId,
timeframe: mockTimeframeMonths,
presetType: PRESET_TYPES.MONTHS,
......@@ -50,7 +51,7 @@ describe('Roadmap Vuex Actions', () => {
basePath,
timeframeStartDate,
timeframeEndDate,
});
};
});
describe('setInitialData', () => {
......@@ -76,7 +77,8 @@ describe('Roadmap Vuex Actions', () => {
actions.receiveEpicsSuccess,
{
rawEpics: [
Object.assign({}, mockRawEpic, {
{
...mockRawEpic,
start_date: '2017-12-31',
end_date: '2018-2-15',
descendantWeightSum: {
......@@ -87,7 +89,7 @@ describe('Roadmap Vuex Actions', () => {
openedEpics: 3,
closedEpics: 2,
},
}),
},
],
},
state,
......@@ -96,14 +98,15 @@ describe('Roadmap Vuex Actions', () => {
{
type: types.RECEIVE_EPICS_SUCCESS,
payload: [
Object.assign({}, mockFormattedEpic, {
{
...mockFormattedEpic,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
originalStartDate: new Date(2017, 11, 31),
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
}),
},
],
},
],
......@@ -112,14 +115,15 @@ describe('Roadmap Vuex Actions', () => {
type: 'initItemChildrenFlags',
payload: {
epics: [
Object.assign({}, mockFormattedEpic, {
{
...mockFormattedEpic,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
originalStartDate: new Date(2017, 11, 31),
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
}),
},
],
},
},
......@@ -148,7 +152,7 @@ describe('Roadmap Vuex Actions', () => {
{ type: types.UPDATE_EPIC_IDS, payload: mockRawEpic.id },
{
type: types.RECEIVE_EPICS_FOR_TIMEFRAME_SUCCESS,
payload: [Object.assign({}, mockFormattedEpic, { newEpic: true })],
payload: [{ ...mockFormattedEpic, newEpic: true }],
},
],
[],
......@@ -352,7 +356,8 @@ describe('Roadmap Vuex Actions', () => {
{
parentItemId: '41',
rawChildren: [
Object.assign({}, mockRawEpic, {
{
...mockRawEpic,
start_date: '2017-12-31',
end_date: '2018-2-15',
descendantWeightSum: {
......@@ -363,7 +368,7 @@ describe('Roadmap Vuex Actions', () => {
openedEpics: 3,
closedEpics: 2,
},
}),
},
],
},
state,
......@@ -373,7 +378,8 @@ describe('Roadmap Vuex Actions', () => {
payload: {
parentItemId: '41',
children: [
Object.assign({}, mockFormattedEpic, {
{
...mockFormattedEpic,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
......@@ -381,7 +387,7 @@ describe('Roadmap Vuex Actions', () => {
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
isChildEpic: true,
}),
},
],
},
},
......@@ -395,7 +401,8 @@ describe('Roadmap Vuex Actions', () => {
type: 'initItemChildrenFlags',
payload: {
epics: [
Object.assign({}, mockFormattedEpic, {
{
...mockFormattedEpic,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
......@@ -403,7 +410,7 @@ describe('Roadmap Vuex Actions', () => {
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
isChildEpic: true,
}),
},
],
},
},
......@@ -680,12 +687,7 @@ describe('Roadmap Vuex Actions', () => {
return testAction(
actions.receiveMilestonesSuccess,
{
rawMilestones: [
Object.assign({}, mockMilestone, {
start_date: '2017-12-31',
end_date: '2018-2-15',
}),
],
rawMilestones: [{ ...mockMilestone, start_date: '2017-12-31', end_date: '2018-2-15' }],
},
state,
[
......@@ -693,14 +695,15 @@ describe('Roadmap Vuex Actions', () => {
{
type: types.RECEIVE_MILESTONES_SUCCESS,
payload: [
Object.assign({}, mockFormattedMilestone, {
{
...mockFormattedMilestone,
startDateOutOfRange: false,
endDateOutOfRange: false,
startDate: new Date(2017, 11, 31),
originalStartDate: new Date(2017, 11, 31),
endDate: new Date(2018, 1, 15),
originalEndDate: new Date(2018, 1, 15),
}),
},
],
},
],
......
......@@ -36,6 +36,4 @@ export const projects = {
],
};
export const withRootStorageStatistics = Object.assign({}, projects, {
totalUsage: 3261070,
});
export const withRootStorageStatistics = { ...projects, totalUsage: 3261070 };
......@@ -19,7 +19,7 @@ describe('MrWidgetPipelineContainer', () => {
const factory = (method = shallowMount, mrUpdates = {}, provide = {}) => {
wrapper = method.call(this, MrWidgetPipelineContainer, {
propsData: {
mr: Object.assign({}, mockStore, mrUpdates),
mr: { ...mockStore, ...mrUpdates },
},
provide: {
...provide,
......
import mockData, { mockStore } from 'jest/vue_mr_widget/mock_data';
export default Object.assign({}, mockData, {
export default {
...mockData,
codeclimate: {
head_path: 'head.json',
base_path: 'base.json',
......@@ -18,7 +19,7 @@ export default Object.assign({}, mockData, {
license_management: false,
secret_scanning: false,
},
});
};
// Codeclimate
export const headIssues = [
......
......@@ -28,9 +28,7 @@ describe('MRWidgetPipeline', () => {
describe('computed', () => {
describe('when upstream pipelines are passed', () => {
beforeEach(() => {
const pipeline = Object.assign({}, mockData.pipeline, {
triggered_by: mockLinkedPipelines.triggered_by,
});
const pipeline = { ...mockData.pipeline, triggered_by: mockLinkedPipelines.triggered_by };
createComponent(pipeline);
});
......@@ -46,9 +44,7 @@ describe('MRWidgetPipeline', () => {
describe('when downstream pipelines are passed', () => {
beforeEach(() => {
const pipeline = Object.assign({}, mockData.pipeline, {
triggered: mockLinkedPipelines.triggered,
});
const pipeline = { ...mockData.pipeline, triggered: mockLinkedPipelines.triggered };
createComponent(pipeline);
});
......
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