mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-01 18:58:10 +08:00
chore(popper): replace lodash with lodash-es
This commit is contained in:
parent
34ad8fe077
commit
4220cb92d0
@ -24,6 +24,10 @@
|
||||
"@storybook/html": "^5.3.19",
|
||||
"@swc-node/jest": "^0.1.9",
|
||||
"@types/jest": "^26.0.7",
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
"@types/lodash": "^4.14.159",
|
||||
>>>>>>> chore(popper): replace lodash with lodash-es
|
||||
"@typescript-eslint/eslint-plugin": "^3.7.0",
|
||||
"@typescript-eslint/parser": "^3.7.0",
|
||||
"@vue/compiler-sfc": "^3.0.0-rc.1",
|
||||
|
@ -1,8 +0,0 @@
|
||||
|
||||
const _ = jest.genMockFromModule('lodash-es')
|
||||
|
||||
const debounce = (fn) => () => fn()
|
||||
|
||||
_.debounce = debounce
|
||||
|
||||
module.exports = _
|
16
packages/popper/__mocks__/lodash.js
Normal file
16
packages/popper/__mocks__/lodash.js
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
const _ = jest.genMockFromModule('lodash')
|
||||
|
||||
|
||||
const debounce = jest.fn(fn => {
|
||||
const caller = () => {
|
||||
return fn()
|
||||
}
|
||||
caller.cancel = jest.fn()
|
||||
caller.flush = jest.fn()
|
||||
return caller
|
||||
})
|
||||
|
||||
_.debounce = debounce
|
||||
|
||||
module.exports = _
|
@ -6,13 +6,14 @@ import ElPopper from '../src/index.vue'
|
||||
|
||||
import type { VueWrapper } from '@vue/test-utils'
|
||||
|
||||
type UnKnownProps = Record<string, unknown>
|
||||
|
||||
jest.mock('lodash')
|
||||
|
||||
const AXIOM = 'Rem is the best girl'
|
||||
const Wrapped = (props: UnKnownProps, { slots }) => h('div', h(ElPopper, props, slots))
|
||||
|
||||
jest.mock('lodash-es')
|
||||
|
||||
const Wrapped = (props, { slots }) => h('div', h(ElPopper, props, slots))
|
||||
|
||||
const Transition = (_, { attrs, slots }) => h('div', attrs, slots)
|
||||
const Transition = (_: UnKnownProps, { attrs, slots }) => h('div', attrs, slots)
|
||||
Transition.displayName = 'Transition'
|
||||
// eslint-disable-next-line
|
||||
const _mount = (props: Record<string, unknown> = {}, slots = {}): VueWrapper<any> =>
|
||||
@ -24,20 +25,23 @@ const _mount = (props: Record<string, unknown> = {}, slots = {}): VueWrapper<any
|
||||
const selector = '[role="tooltip"]'
|
||||
|
||||
|
||||
const popperMock = jest.spyOn(popperExports, 'createPopper').mockImplementation(() => ({
|
||||
update: jest.fn(),
|
||||
forceUpdate: jest.fn(),
|
||||
setOptions: jest.fn(),
|
||||
destroy: jest.fn(),
|
||||
state: null,
|
||||
}))
|
||||
|
||||
describe('Popper.vue', () => {
|
||||
let popperMock
|
||||
// eslint-disable-next-line
|
||||
// eslint-disable-next-line
|
||||
const oldTransition = Vue.Transition
|
||||
beforeAll(() => {
|
||||
popperMock = jest.spyOn(popperExports, 'createPopper').mockImplementation(() => ({
|
||||
update: jest.fn(),
|
||||
forceUpdate: jest.fn(),
|
||||
setOptions: jest.fn(),
|
||||
destroy: jest.fn(),
|
||||
state: null,
|
||||
}))
|
||||
// eslint-disable-next-line
|
||||
;(Vue as any).Transition = Transition
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
popperMock.mockReset()
|
||||
// eslint-disable-next-line
|
||||
@ -110,6 +114,7 @@ describe('Popper.vue', () => {
|
||||
})
|
||||
expect(wrapper.find(selector).attributes('style')).toContain('display: none')
|
||||
await wrapper.find(selector).trigger('mouseenter')
|
||||
|
||||
expect(wrapper.find(selector).attributes('style')).toContain('display: none')
|
||||
await wrapper.setProps({
|
||||
value: true,
|
||||
@ -134,8 +139,8 @@ describe('Popper.vue', () => {
|
||||
await wrapper.setProps({
|
||||
disabled: false,
|
||||
})
|
||||
|
||||
await wrapper.find(selector).trigger('mouseenter')
|
||||
|
||||
expect(wrapper.find(selector).attributes('style')).not.toContain('display: none')
|
||||
})
|
||||
|
||||
|
@ -32,11 +32,10 @@ import {
|
||||
ref,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
watch,
|
||||
} from 'vue'
|
||||
import { isArray } from '@vue/shared'
|
||||
import { debounce } from 'lodash-es'
|
||||
import { debounce } from 'lodash'
|
||||
import { createPopper } from '@popperjs/core'
|
||||
|
||||
import { generateId } from '@element-plus/utils/util'
|
||||
|
@ -1 +0,0 @@
|
||||
export const PopupManager = {}
|
@ -1,9 +1,6 @@
|
||||
import isServer from './isServer'
|
||||
import isObject from 'lodash/isObject'
|
||||
import castArray from 'lodash/castArray'
|
||||
import isEmpty from 'lodash/isEmpty'
|
||||
import isEqual from 'lodash/isEqual'
|
||||
import capitalize from 'lodash/capitalize'
|
||||
import { isObject, capitalize } from '@vue/shared'
|
||||
import {isEmpty, castArray, isEqual} from 'lodash'
|
||||
|
||||
const { hasOwnProperty } = Object.prototype
|
||||
|
||||
|
@ -11,7 +11,9 @@
|
||||
"sourceMap": true,
|
||||
"lib": [
|
||||
"es2020", "dom"
|
||||
]
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
|
20
yarn.lock
20
yarn.lock
@ -2849,17 +2849,10 @@
|
||||
"@types/koa-compose" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/lodash-es@^4.17.3":
|
||||
version "4.17.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.3.tgz#87eb0b3673b076b8ee655f1890260a136af09a2d"
|
||||
integrity sha512-iHI0i7ZAL1qepz1Y7f3EKg/zUMDwDfTzitx+AlHhJJvXwenP682ZyGbgPSc5Ej3eEAKVbNWKFuwOadCj5vBbYQ==
|
||||
dependencies:
|
||||
"@types/lodash" "*"
|
||||
|
||||
"@types/lodash@*":
|
||||
version "4.14.158"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.158.tgz#b38ea8b6fe799acd076d7a8d7ab71c26ef77f785"
|
||||
integrity sha512-InCEXJNTv/59yO4VSfuvNrZHt7eeNtWQEgnieIA+mIC+MOWM9arOWG2eQ8Vhk6NbOre6/BidiXhkZYeDY9U35w==
|
||||
"@types/lodash@^4.14.159":
|
||||
version "4.14.159"
|
||||
resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.159.tgz#61089719dc6fdd9c5cb46efc827f2571d1517065"
|
||||
integrity sha512-gF7A72f7WQN33DpqOWw9geApQPh4M3PxluMtaHxWHXEGSN12/WbcEk/eNSqWNQcQhF66VSZ06vCF94CrHwXJDg==
|
||||
|
||||
"@types/lru-cache@^5.1.0":
|
||||
version "5.1.0"
|
||||
@ -9585,11 +9578,6 @@ locate-path@^5.0.0:
|
||||
dependencies:
|
||||
p-locate "^4.1.0"
|
||||
|
||||
lodash-es@^4.17.15:
|
||||
version "4.17.15"
|
||||
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.15.tgz#21bd96839354412f23d7a10340e5eac6ee455d78"
|
||||
integrity sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ==
|
||||
|
||||
lodash._reinterpolate@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
|
||||
|
Loading…
Reference in New Issue
Block a user