Skip to content

Commit

Permalink
switch to lodash-es
Browse files Browse the repository at this point in the history
  • Loading branch information
leem42 committed Feb 5, 2020
1 parent 73e4c68 commit b0e5c71
Show file tree
Hide file tree
Showing 37 changed files with 243 additions and 236 deletions.
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"presets": [
"@babel/preset-react",
"@babel/preset-env",
"@babel/preset-typescript",
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread",
"@babel/proposal-object-rest-spread"
]
}
}
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/enzyme-adapter-react-16": "^1.0.5",
"@types/jquery": "^3.3.6",
"@types/katex": "^0.10.2",
"@types/lodash": "^4.14.119",
"@types/lodash-es": "4.17.3",
"@types/react-jsonschema-form": "^1.3.2",
"@types/react-mailchimp-subscribe": "^2.0.2",
"@types/react-measure": "^2.0.4",
Expand All @@ -38,7 +38,7 @@
"json-rules-engine": "^4.0.0",
"json-schema-ref-parser": "^7.1.1",
"katex": "0.11.1",
"lodash.clonedeep": "^4.5.0",
"lodash-es": "4.17.5",
"markdown-it": "^8.4.2",
"markdown-it-br": "^1.0.0",
"markdown-it-center-text": "^1.0.4",
Expand Down Expand Up @@ -75,7 +75,8 @@
"rss-parser": "^3.7.2",
"sanitize-html": "^1.18.4",
"spark-md5": "^3.0.0",
"sql-parser": "^0.5.0"
"sql-parser": "^0.5.0",
"universal-cookie": "^4.0.3"
},
"devDependencies": {
"@babel/cli": "^7.4.3",
Expand Down Expand Up @@ -104,7 +105,6 @@
"eslint-plugin-react-hooks": "^2.3.0",
"npm": "^6.9.0",
"npm-run-all": "^4.1.3",
"universal-cookie": "^4.0.3",
"regenerator-runtime": "^0.13.2",
"rollup": "^1.16.0",
"rollup-plugin-babel": "^4.3.3",
Expand All @@ -129,12 +129,11 @@
"watch-css": "yarn run build-css && node-sass src/ -o src/ --watch --recursive",
"start-js": "react-scripts start",
"start": "npm-run-all -p watch-css start-js",
"test": "react-scripts test --env=jsdom --setupFiles ./src/setupTests.js",
"test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!(lodash-es|jest*)/)\" , --env=jsdom --setupFiles ./src/setupTests.js",
"test:coverage": "yarn test --coverage",
"test:noPrompt": "CI=true yarn test",
"eject": "react-scripts eject",
"type-check": "tsc --noEmit",
"tslintfix": "./node_modules/tslint/bin/tslint --project tsconfig.json --fix --",
"type-check:watch": "yarn run type-check --watch",
"build": "yarn run build-css && yarn run build:js && yarn run build:copy-assets && yarn build:rollup",
"build:js": "tsc --p tsconfig.build.json",
Expand All @@ -145,7 +144,6 @@
"fstream": "1.0.12",
"js-yaml": "3.13.1",
"minimatch": "3.0.4",
"lodash": "^4.17.11",
"mem": "^4.0.0",
"react": "16.12.0",
"react-dom": "16.12.0"
Expand Down
2 changes: 2 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default {
'sanitizeHtml',
'react-transition-group',
'sql-parser',
'universal-cookie',
],
onwarn: function(warning) {
// Skip certain warnings
Expand Down Expand Up @@ -117,6 +118,7 @@ export default {
sanitizeHtml: 'sanitizeHtml',
'prop-types': 'PropTypes',
'sql-parser': 'sqlParser',
'universal-cookie': 'UniversalCookie',
},
format: 'umd',
name: 'SRC',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/lib/containers/CardContainer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import CardContainer, {
CardContainerProps,
} from '../../../lib/containers/CardContainer'
import TotalQueryResults from '../../../lib/containers/TotalQueryResults'
import { cloneDeep } from '../../../lib/utils/functions'
import {
QueryBundleRequest,
QueryResultBundle,
} from '../../../lib/utils/synapseTypes/'
import syn16787123Json from '../../../mocks/syn16787123.json'
import { cloneDeep } from 'lodash-es'

const createShallowComponent = (props: CardContainerProps) => {
const wrapper = shallow(<CardContainer {...props} />)
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/lib/containers/Facets.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { QueryWrapperChildProps } from '../../../lib/containers/QueryWrapper'
import { SynapseConstants } from '../../../lib'
import syn16787123Json from '../../../mocks/syn16787123.json'
import { QueryResultBundle } from '../../../lib/utils/synapseTypes/'
import { cloneDeep } from '../../../lib/utils/functions'
import {} from '../../../lib/utils/functions'
import TotalQueryResults from '../../../lib/containers/TotalQueryResults'
import { SELECT_ALL } from 'lib/containers/table/SynapseTableConstants'
import { cloneDeep } from 'lodash-es'

const createMountedComponent = (props: QueryWrapperChildProps) => {
const wrapper = mount(<Facets {...props} />)
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/lib/containers/QueryWrapper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import QueryWrapper, {
} from '../../../lib/containers/QueryWrapper'
import syn16787123Json from '../../../mocks/syn16787123.json'
import { SynapseConstants } from '../../../lib/utils/'
import { cloneDeep } from '../../../lib/utils/functions'
import { QueryBundleRequest } from 'lib/utils/synapseTypes/'
import { cloneDeep } from 'lodash-es'

// utility function
const createShallowComponent = async (
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/lib/containers/SynapseTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
Row,
QueryBundleRequest,
} from 'lib/utils/synapseTypes/'
import { Dictionary } from 'lodash'
import * as React from 'react'
import { Modal } from 'react-bootstrap'
import { SynapseConstants } from '../../../lib'
Expand All @@ -24,9 +23,10 @@ import { QueryWrapperChildProps } from '../../../lib/containers/QueryWrapper'
import SynapseTable, {
SORT_STATE,
SynapseTableProps,
Dictionary,
} from '../../../lib/containers/table/SynapseTable'
import { cloneDeep } from '../../../lib/utils/functions'
import syn16787123Json from '../../../mocks/syn16787123.json'
import { cloneDeep } from 'lodash-es'

const createShallowComponent = (
props: SynapseTableProps & QueryWrapperChildProps,
Expand All @@ -41,7 +41,7 @@ describe('basic functionality', () => {
// setup tests
const title = 'studies'
const synapseId = 'syn16787123'
const castData = syn16787123Json as QueryResultBundle
const castData = syn16787123Json
const totalColumns = 13
const lastQueryRequest: QueryBundleRequest = {
concreteType: 'org.sagebionetworks.repo.model.table.QueryBundleRequest',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/lib/containers/TotalQueryResults.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { shallow } from 'enzyme'
import { cloneDeep } from 'lodash'
import { cloneDeep } from 'lodash-es'
import * as React from 'react'
import TotalQueryResults, {
TotalQueryResultsProps,
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/lib/containers/queryUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getNextPageOfData, cloneDeep } from '../../../lib/utils/functions'
import { getNextPageOfData } from '../../../lib/utils/functions'
import { SynapseConstants } from '../../../lib/utils'
import syn16787123Json from '../../../mocks/syn16787123.json'
import { QueryResultBundle } from 'src/lib/utils/synapseTypes/Table/QueryResultBundle.js'
import { cloneDeep } from 'lodash-es'

describe('get next page of data', () => {
const sql = 'SELECT * FROM syn16787123'
Expand All @@ -11,6 +12,7 @@ describe('get next page of data', () => {
SynapseConstants.BUNDLE_MASK_QUERY_COLUMN_MODELS |
SynapseConstants.BUNDLE_MASK_QUERY_FACETS |
SynapseConstants.BUNDLE_MASK_QUERY_RESULTS,
entityId: 'syn16787123',
query: {
sql,
isConsistent: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { shallow } from 'enzyme'
import * as _ from 'lodash'
import * as _ from 'lodash-es'
import {
Step,
NavActionEnum,
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('NavButtons tests', () => {

it('should callback with correct params', async () => {
const spy = jest.spyOn(mock, 'onNavActionFn')
let { wrapper } = createShallowNavButtonsComponent(props)
const { wrapper } = createShallowNavButtonsComponent(props)
wrapper.find('button.prev').simulate('click')
expect(spy).toHaveBeenCalledWith(NavActionEnum.PREVIOUS)
})
Expand All @@ -77,7 +77,7 @@ describe('NavButtons tests', () => {

it('should callback with correct params', () => {
const spy = jest.spyOn(mock, 'onNavActionFn')
let { wrapper } = createShallowNavButtonsComponent(props)
const { wrapper } = createShallowNavButtonsComponent(props)
wrapper.find('button.next').simulate('click')
expect(spy).toHaveBeenCalledWith(NavActionEnum.NEXT)
wrapper.find('button.save').simulate('click')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { shallow } from 'enzyme'
import * as _ from 'lodash'
import * as _ from 'lodash-es'
import { Step } from '../../../../lib/containers/synapse_form_wrapper/types'
import StepsSideNav, {
StepsSideNavProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { shallow, mount } from 'enzyme'
import * as _ from 'lodash'
import { mount } from 'enzyme'
import * as _ from 'lodash-es'
import { Step } from '../../../../lib/containers/synapse_form_wrapper/types'
import SummaryTable, {
SummaryTableProps,
Expand Down Expand Up @@ -28,7 +28,7 @@ describe('basic tests', () => {
callbackFn: jest.fn(() => 'ok'),
}

let { efficacy, basic, naming } = submissionData
const { efficacy, basic, naming } = submissionData

const props: SummaryTableProps = {
isWizard: true,
Expand Down Expand Up @@ -83,13 +83,13 @@ describe('basic tests', () => {
expect(Object.keys(_props.formData.basic).indexOf('reqtextfield')).not.toBe(
-1,
)
expect(_props.formData.basic.reqtextfield).toBeUndefined
expect(_props.formData.basic.reqtextfield).toBeUndefined()
expect(wrapper.text().indexOf('reqtextfield')).toBe(-1)

expect(
Object.keys(_props.formData.naming).indexOf('chemical_name'),
).not.toBe(-1)
expect(_props.formData.naming.chemical_name).not.toBeUndefined
expect(_props.formData.naming.chemical_name).not.toBeUndefined()
expect(wrapper.text().indexOf('Chemical Name')).not.toBe(-1)

const firstColumns = wrapper.find('td:first-child')
Expand All @@ -112,11 +112,11 @@ describe('basic tests', () => {

const cell1 = wrapper.findWhere(
n =>
n.html() ==
n.html() ===
'<td>[1] What cell line was used for the efficacy assay?</td>',
)
const cell2 = wrapper.findWhere(
n => n.html() == '<td>Cell Line Efficacy Value</td>',
n => n.html() === '<td>Cell Line Efficacy Value</td>',
)

expect(cell1).toHaveLength(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'
import { shallow } from 'enzyme'
import { Engine } from 'json-rules-engine'
import $RefParser from 'json-schema-ref-parser'
import _ from 'lodash'
import _ from 'lodash-es'

import SynapseForm, {
SynapseFormProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
mockFormData,
mockFormSchema as formschemaJson,
} from '../../../../mocks/mock_drug_tool_data'
import _ from 'lodash'
import _ from 'lodash-es'

const SynapseClient = require('../../../../lib/utils/SynapseClient')
const token: string = '123444'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { mount } from 'enzyme'
import * as _ from 'lodash'
import * as _ from 'lodash-es'

import WarningModal, {
WarningModalProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import _ from 'lodash'
import _ from 'lodash-es'
import { render, fireEvent, cleanup } from '@testing-library/react'
import { ElementWithTooltip } from '../../../../lib/containers/widgets/ElementWithTooltip'
import { faCheck, IconDefinition } from '@fortawesome/free-solid-svg-icons'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import {
QueryFilterProps,
QueryFilter,
} from '../../../../../lib/containers/widgets/query-filter/QueryFilter'
import {

QueryResultBundle,
} from '../../../../../lib/utils/synapseTypes'
import { QueryResultBundle } from '../../../../../lib/utils/synapseTypes'

import _ from 'lodash'
import _ from 'lodash-es'

import mockQueryResponseData from '../../../../../mocks/mockQueryResponseData.json'

Expand Down Expand Up @@ -102,7 +99,7 @@ describe('handling child component callbacks', () => {

const enumWrapper = wrapper.find('EnumFacetFilter').at(0)
enumWrapper.simulate('change', 'Ford', true)

expect(mockApplyChanges).toHaveBeenCalledWith(expectedResult)
})

Expand Down
Loading

0 comments on commit b0e5c71

Please sign in to comment.