Commit ae082172 authored by Mike Greiling's avatar Mike Greiling

Merge branch '196642-replace-underscore-with-lodash-for-ee-spec' into 'master'

Replace all instances of underscore to lodash in ee/spec

Closes #196642

See merge request gitlab-org/gitlab!26417
parents 434e6f08 9bb6c825
<script>
import _ from 'underscore';
import { delay } from 'lodash';
import epicItemDetails from './epic_item_details.vue';
import epicItemTimeline from './epic_item_timeline.vue';
......@@ -78,7 +78,7 @@ export default {
removeHighlight() {
if (this.epic.newEpic) {
this.$nextTick(() => {
_.delay(() => {
delay(() => {
this.epic.newEpic = false;
}, EPIC_HIGHLIGHT_REMOVE_AFTER);
});
......
import { uniq } from 'underscore';
import { uniq } from 'lodash';
import { TEST_HOST } from 'helpers/test_constants';
import { getJSONFixture } from 'helpers/fixtures';
import mutations from 'ee/analytics/cycle_analytics/store/mutations';
......
import { isNumber } from 'underscore';
import { isNumber } from 'lodash';
import { getDatesInRange } from '~/lib/utils/datetime_utility';
import {
isStartEvent,
......
import _ from 'underscore';
import { uniqueId } from 'lodash';
import { shallowMount } from '@vue/test-utils';
import { GlFormTextarea, GlFormCheckbox, GlDeprecatedButton } from '@gitlab/ui';
import Form from 'ee/feature_flags/components/form.vue';
......@@ -156,7 +156,7 @@ describe('feature flag form', () => {
it('should update the scope', () => {
wrapper.find(ToggleButton).vm.$emit('change', false);
expect(_.first(wrapper.vm.formScopes).active).toBe(false);
expect(wrapper.vm.formScopes[0].active).toBe(false);
});
it('should be disabled if the feature flag is not active', done => {
......@@ -185,7 +185,7 @@ describe('feature flag form', () => {
});
it('should add `shouldBeDestroyed` key the clicked scope', () => {
expect(_.first(wrapper.vm.formScopes).shouldBeDestroyed).toBe(true);
expect(wrapper.vm.formScopes[0].shouldBeDestroyed).toBe(true);
});
it('should not render deleted scopes', () => {
......@@ -203,7 +203,7 @@ describe('feature flag form', () => {
{
environmentScope: 'new_scope',
active: false,
id: _.uniqueId(INTERNAL_ID_PREFIX),
id: uniqueId(INTERNAL_ID_PREFIX),
canUpdate: true,
protected: false,
strategies: [
......
import _ from 'underscore';
import { uniqueId } from 'lodash';
import {
mapToScopesViewModel,
mapFromScopesViewModel,
......@@ -214,7 +214,7 @@ describe('feature flags helpers spec', () => {
it('should strip out internal IDs', () => {
const input = {
scopes: [{ id: 3 }, { id: _.uniqueId(INTERNAL_ID_PREFIX) }],
scopes: [{ id: 3 }, { id: uniqueId(INTERNAL_ID_PREFIX) }],
};
const result = mapFromScopesViewModel(input);
......@@ -380,16 +380,14 @@ describe('feature flags helpers spec', () => {
});
it('inserts spaces between user ids', () => {
const strategy = _.first(
mapStrategiesToViewModel([
{
id: '1',
name: 'userWithId',
parameters: { userIds: 'user1,user2,user3' },
scopes: [],
},
]),
);
const strategy = mapStrategiesToViewModel([
{
id: '1',
name: 'userWithId',
parameters: { userIds: 'user1,user2,user3' },
scopes: [],
},
])[0];
expect(strategy.parameters).toEqual({ userIds: 'user1, user2, user3' });
});
......@@ -492,7 +490,7 @@ describe('feature flags helpers spec', () => {
],
});
const strategyAttrs = _.first(result.operations_feature_flag.strategies_attributes);
const strategyAttrs = result.operations_feature_flag.strategies_attributes[0];
expect(strategyAttrs.parameters).toEqual({ userIds: 'user1,user2,user3' });
});
......
import _ from 'underscore';
import { escape as esc } from 'lodash';
import { TEST_HOST } from 'spec/test_constants';
import * as messages from 'ee/ide/stores/modules/terminal/messages';
import { sprintf } from '~/locale';
......@@ -15,7 +15,7 @@ describe('EE IDE store terminal messages', () => {
sprintf(
messages.ERROR_CONFIG,
{
helpStart: `<a href="${_.escape(TEST_HELP_URL)}" target="_blank">`,
helpStart: `<a href="${esc(TEST_HELP_URL)}" target="_blank">`,
helpEnd: '</a>',
},
false,
......
import Vue from 'vue';
import _ from 'underscore';
import _ from 'lodash';
import epicItemComponent from 'ee/roadmap/components/epic_item.vue';
......@@ -11,6 +11,14 @@ import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate, mockEpic, mockGroupId } from 'ee_jest/roadmap/mock_data';
jest.mock('lodash/delay', () =>
jest.fn(func => {
// eslint-disable-next-line no-param-reassign
func.delay = jest.fn();
return func;
}),
);
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
const createComponent = ({
......@@ -111,8 +119,6 @@ describe('EpicItemComponent', () => {
describe('methods', () => {
describe('removeHighlight', () => {
it('should call _.delay after 3 seconds with a callback function which would set `epic.newEpic` to false when it is true already', done => {
jest.spyOn(_, 'delay').mockImplementation(() => {});
vm.epic.newEpic = true;
vm.removeHighlight();
......
import _ from 'underscore';
import { shallowMount } from '@vue/test-utils';
import { GlDeprecatedButton, GlLoadingIcon } from '@gitlab/ui';
import ApprovalsList from 'ee/vue_merge_request_widget/components/approvals/approvals_list.vue';
......@@ -6,7 +5,7 @@ import ApprovalsFooter from 'ee/vue_merge_request_widget/components/approvals/ap
import Icon from '~/vue_shared/components/icon.vue';
import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue';
const testSuggestedApprovers = () => _.range(1, 11).map(id => ({ id }));
const testSuggestedApprovers = () => Array.from({ length: 11 }, (_, i) => i).map(id => ({ id }));
const testApprovalRules = () => [{ name: 'Lorem' }, { name: 'Ipsum' }];
describe('EE MRWidget approvals footer', () => {
......
import { shallowMount } from '@vue/test-utils';
import _ from 'underscore';
import ApprovedIcon from 'ee/vue_merge_request_widget/components/approvals/approved_icon.vue';
import ApprovalsList from 'ee/vue_merge_request_widget/components/approvals/approvals_list.vue';
import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue';
const testApprovers = () => _.range(1, 11).map(id => ({ id }));
const testApprovers = () => Array.from({ length: 11 }, (_, i) => i).map(id => ({ id }));
const testRuleApproved = () => ({
id: 1,
name: 'Lorem',
......
import { shallowMount } from '@vue/test-utils';
import _ from 'underscore';
import { APPROVED_MESSAGE } from 'ee/vue_merge_request_widget/components/approvals/messages';
import ApprovalsSummary from 'ee/vue_merge_request_widget/components/approvals/approvals_summary.vue';
import { toNounSeriesText } from '~/lib/utils/grammar';
import UserAvatarList from '~/vue_shared/components/user_avatar/user_avatar_list.vue';
const testApprovers = () => _.range(1, 5).map(id => ({ id }));
const testApprovers = () => Array.from({ length: 5 }, (_, i) => i).map(id => ({ id }));
const testRulesLeft = () => ['Lorem', 'Ipsum', 'dolar sit'];
const TEST_APPROVALS_LEFT = 3;
......
import { shallowMount } from '@vue/test-utils';
import { uniqueId } from 'lodash';
import { AccordionItem } from 'ee/vue_shared/components/accordion';
import accordionEventBus from 'ee/vue_shared/components/accordion/accordion_event_bus';
import { uniqueId } from 'lodash';
jest.mock('ee/vue_shared/components/accordion/accordion_event_bus', () => ({
$on: jest.fn(),
......
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