mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
test(components): removing mock folder (#5911)
- Remove mock folder from the project root - Add mock for each component test file accordingly
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
module.exports = jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
})
|
||||
@@ -1,6 +0,0 @@
|
||||
const _ = jest.requireActual('lodash')
|
||||
|
||||
_.debounce = require('./debounce')
|
||||
_.throttle = require('./throttle')
|
||||
|
||||
module.exports = _
|
||||
@@ -1,5 +0,0 @@
|
||||
module.exports = jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
})
|
||||
@@ -6,6 +6,17 @@ import { ArrowDown, Check, CircleClose } from '@element-plus/icons-vue'
|
||||
import { POPPER_CONTAINER_SELECTOR } from '@element-plus/hooks'
|
||||
import Cascader from '../src/index.vue'
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
...(jest.requireActual('lodash-unified') as Record<string, any>),
|
||||
debounce: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
const OPTIONS = [
|
||||
{
|
||||
value: 'zhejiang',
|
||||
|
||||
@@ -5,6 +5,17 @@ import type { ComponentPublicInstance } from 'vue'
|
||||
|
||||
import type { Nullable } from '@element-plus/utils/types'
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
...(jest.requireActual('lodash-unified') as Record<string, any>),
|
||||
debounce: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
const _mount = (template: string, data: () => { [key: string]: any }) => {
|
||||
const Component = defineComponent({
|
||||
components: {
|
||||
|
||||
@@ -3,6 +3,16 @@ import { mount } from '@vue/test-utils'
|
||||
import { tick, defineGetter, makeScroll } from '@element-plus/test-utils'
|
||||
import InfiniteScroll, { SCOPE, DEFAULT_DELAY } from '../src/index'
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
throttle: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
const CONTAINER_HEIGHT = 200
|
||||
const ITEM_HEIGHT = 100
|
||||
const CONTAINER_STYLE = `overflow-y: auto;`
|
||||
|
||||
@@ -8,6 +8,17 @@ import { hasClass } from '@element-plus/utils/dom'
|
||||
import { POPPER_CONTAINER_SELECTOR } from '@element-plus/hooks'
|
||||
import Select from '../src/select.vue'
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
...(jest.requireActual('lodash-unified') as Record<string, any>),
|
||||
debounce: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
jest.useFakeTimers()
|
||||
|
||||
const _mount = makeMountFunc({
|
||||
|
||||
@@ -7,6 +7,17 @@ import Select from '../src/select.vue'
|
||||
import Group from '../src/option-group.vue'
|
||||
import Option from '../src/option.vue'
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
...(jest.requireActual('lodash-unified') as Record<string, any>),
|
||||
debounce: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
jest.useFakeTimers()
|
||||
|
||||
interface SelectProps {
|
||||
|
||||
@@ -2,6 +2,17 @@ import { h, nextTick } from 'vue'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import Slider from '../src/index.vue'
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
...(jest.requireActual('lodash-unified') as Record<string, any>),
|
||||
debounce: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
describe('Slider', () => {
|
||||
it('create', () => {
|
||||
const wrapper = mount(Slider)
|
||||
|
||||
@@ -4,6 +4,17 @@ import ElTable from '../src/table.vue'
|
||||
import ElTableColumn from '../src/table-column/index'
|
||||
import { mount, getTestData } from './table-test-common'
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
...(jest.requireActual('lodash-unified') as Record<string, any>),
|
||||
debounce: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
describe('table column', () => {
|
||||
describe('column attributes', () => {
|
||||
const createTable = function (
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { mount as _mount } from '@vue/test-utils'
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
...(jest.requireActual('lodash-unified') as Record<string, any>),
|
||||
debounce: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
export const mount = (opt: any) =>
|
||||
_mount<any>(opt, {
|
||||
attachTo: 'body',
|
||||
|
||||
@@ -10,6 +10,17 @@ import type { ComponentPublicInstance } from 'vue'
|
||||
|
||||
const { CheckboxGroup: ElCheckboxGroup } = ElCheckbox
|
||||
|
||||
jest.mock('lodash-unified', () => {
|
||||
return {
|
||||
...(jest.requireActual('lodash-unified') as Record<string, any>),
|
||||
debounce: jest.fn((fn) => {
|
||||
fn.cancel = jest.fn()
|
||||
fn.flush = jest.fn()
|
||||
return fn
|
||||
}),
|
||||
}
|
||||
})
|
||||
|
||||
jest.useFakeTimers()
|
||||
|
||||
describe('Table.vue', () => {
|
||||
|
||||
Reference in New Issue
Block a user