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