D2Admin 1.7

Former-commit-id: 3010ce31114fdc121006451c72f9e18306239fd2
This commit is contained in:
liyang
2019-05-07 09:26:18 +08:00
parent 46bc6ca451
commit d07d15ed8c
952 changed files with 171232 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
module.exports = {
env: {
jest: true
},
rules: {
'import/no-extraneous-dependencies': 'off'
}
}
+55
View File
@@ -0,0 +1,55 @@
import { mount } from '@vue/test-utils'
import D2ContainerCardBs from '@/components/d2-container/components/d2-container-card-bs.vue'
describe('d2-container-card-bs', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ContainerCardBs)
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2ContainerCardBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.is('.d2-container-card-bs')).toBeTruthy()
expect(wrapper.contains('.d2-container-card-bs__header')).toBeTruthy()
expect(wrapper.contains('.d2-container-card-bs__body')).toBeTruthy()
expect(wrapper.contains('.d2-container-card-bs__body-card')).toBeTruthy()
expect(wrapper.contains('.d2-container-card-bs__footer')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ContainerCardBs, {
propsData: {
betterScrollOptions: {}
}
})
expect(wrapper.props().betterScrollOptions).toEqual({})
})
// 渲染slot
it('has one or more slots', () => {
const wrapper = mount(D2ContainerCardBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.text()).toMatch('header')
expect(wrapper.text()).toMatch('body')
expect(wrapper.text()).toMatch('footer')
})
})
+55
View File
@@ -0,0 +1,55 @@
import { mount } from '@vue/test-utils'
import D2ContainerCard from '@/components/d2-container/components/d2-container-card.vue'
describe('d2-container-card', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ContainerCard)
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2ContainerCard, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.is('.d2-container-card')).toBeTruthy()
expect(wrapper.contains('.d2-container-card__header')).toBeTruthy()
expect(wrapper.contains('.d2-container-card__body')).toBeTruthy()
expect(wrapper.contains('.d2-container-card__body-card')).toBeTruthy()
expect(wrapper.contains('.d2-container-card__footer')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ContainerCard, {
propsData: {
scrollDelay: 30
}
})
expect(wrapper.props().scrollDelay).toEqual(30)
})
// 渲染slot
it('has one or more slots', () => {
const wrapper = mount(D2ContainerCard, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.text()).toMatch('header')
expect(wrapper.text()).toMatch('body')
expect(wrapper.text()).toMatch('footer')
})
})
+35
View File
@@ -0,0 +1,35 @@
import { mount } from '@vue/test-utils'
import D2ContainerFrame from '@/components/d2-container-frame/index.vue'
describe('d2-container-frame', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ContainerFrame, {
stubs: ['d2-container']
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2ContainerFrame, {
stubs: ['d2-container']
})
expect(wrapper.contains('.d2-container-frame')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ContainerFrame, {
stubs: ['d2-container'],
propsData: {
src: 'https://doc.d2admin.fairyever.com/zh/'
}
})
expect(wrapper.props().src).toEqual('https://doc.d2admin.fairyever.com/zh/')
})
})
+55
View File
@@ -0,0 +1,55 @@
import { mount } from '@vue/test-utils'
import D2ContainerFullBs from '@/components/d2-container/components/d2-container-full-bs.vue'
describe('d2-container-full-bs', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ContainerFullBs)
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2ContainerFullBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.is('.d2-container-full-bs')).toBeTruthy()
expect(wrapper.contains('.d2-container-full-bs__header')).toBeTruthy()
expect(wrapper.contains('.d2-container-full-bs__body')).toBeTruthy()
expect(wrapper.contains('.d2-container-full-bs__body-wrapper-inner')).toBeTruthy()
expect(wrapper.contains('.d2-container-full-bs__footer')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ContainerFullBs, {
propsData: {
betterScrollOptions: {}
}
})
expect(wrapper.props().betterScrollOptions).toEqual({})
})
// 渲染slot
it('has one or more slots', () => {
const wrapper = mount(D2ContainerFullBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.text()).toMatch('header')
expect(wrapper.text()).toMatch('body')
expect(wrapper.text()).toMatch('footer')
})
})
+54
View File
@@ -0,0 +1,54 @@
import { mount } from '@vue/test-utils'
import D2ContainerFull from '@/components/d2-container/components/d2-container-full.vue'
describe('d2-container-full', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ContainerFull)
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2ContainerFull, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.is('.d2-container-full')).toBeTruthy()
expect(wrapper.contains('.d2-container-full__header')).toBeTruthy()
expect(wrapper.contains('.d2-container-full__body')).toBeTruthy()
expect(wrapper.contains('.d2-container-full__footer')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ContainerFull, {
propsData: {
scrollDelay: 30
}
})
expect(wrapper.props().scrollDelay).toEqual(30)
})
// 渲染slot
it('has one or more slots', () => {
const wrapper = mount(D2ContainerFull, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.text()).toMatch('header')
expect(wrapper.text()).toMatch('body')
expect(wrapper.text()).toMatch('footer')
})
})
+65
View File
@@ -0,0 +1,65 @@
import { mount } from '@vue/test-utils'
import D2ContainerGhostBs from '@/components/d2-container/components/d2-container-ghost-bs.vue'
describe('d2-container-ghost-bs', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ContainerGhostBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2ContainerGhostBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.is('.d2-container-ghost-bs')).toBeTruthy()
expect(wrapper.contains('.d2-container-ghost-bs__header')).toBeTruthy()
expect(wrapper.contains('.d2-container-ghost-bs__body')).toBeTruthy()
expect(wrapper.contains('.d2-container-ghost-bs__footer')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ContainerGhostBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
},
propsData: {
betterScrollOptions: {}
}
})
expect(wrapper.props().betterScrollOptions).toEqual({})
})
// 渲染slot
it('has one or more slots', () => {
const wrapper = mount(D2ContainerGhostBs, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.text()).toMatch('header')
expect(wrapper.text()).toMatch('body')
expect(wrapper.text()).toMatch('footer')
})
})
+54
View File
@@ -0,0 +1,54 @@
import { mount } from '@vue/test-utils'
import D2ContainerGhost from '@/components/d2-container/components/d2-container-ghost.vue'
describe('d2-container-ghost', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ContainerGhost)
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2ContainerGhost, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.is('.d2-container-ghost')).toBeTruthy()
expect(wrapper.contains('.d2-container-ghost__header')).toBeTruthy()
expect(wrapper.contains('.d2-container-ghost__body')).toBeTruthy()
expect(wrapper.contains('.d2-container-ghost__footer')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ContainerGhost, {
propsData: {
scrollDelay: 30
}
})
expect(wrapper.props().scrollDelay).toEqual(30)
})
// 渲染slot
it('has one or more slots', () => {
const wrapper = mount(D2ContainerGhost, {
slots: {
default: '<div>body</div>',
header: '<div>header</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.text()).toMatch('header')
expect(wrapper.text()).toMatch('body')
expect(wrapper.text()).toMatch('footer')
})
})
+72
View File
@@ -0,0 +1,72 @@
import { mount } from '@vue/test-utils'
import D2CountUp from '@/components/d2-count-up/index.vue'
describe('d2-count-up', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2CountUp, {
propsData: {
end: 100
}
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2CountUp, {
propsData: {
start: 0,
end: 100,
decimals: 0,
duration: 2,
options: {}
}
})
expect(wrapper.props().start).toEqual(0)
expect(wrapper.props().end).toEqual(100)
expect(wrapper.props().decimals).toEqual(0)
expect(wrapper.props().duration).toEqual(2)
expect(wrapper.props().options).toEqual({})
})
// 开始数字,1秒后结束数字
it('start number is 1, 1s later, end number is 99', (done) => {
const wrapper = mount(D2CountUp, {
propsData: {
start: 1,
end: 99,
duration: 1
}
})
expect(wrapper.text()).toBe('1')
setTimeout(() => {
expect(wrapper.text()).toBe('99')
done()
}, 1100)
})
// 小数位数
it('start number is 1.00, 1s later, end number is 99.00', (done) => {
const wrapper = mount(D2CountUp, {
propsData: {
start: 1,
end: 99,
decimals: 2,
duration: 1
}
})
expect(wrapper.text()).toBe('1.00')
setTimeout(() => {
expect(wrapper.text()).toBe('99.00')
done()
}, 1100)
})
})
+39
View File
@@ -0,0 +1,39 @@
import { mount, createLocalVue } from '@vue/test-utils'
import D2IconSelect from '@/components/d2-icon-select/index.vue'
import ElementUI from 'element-ui'
describe('d2-icon-select', () => {
const localVue = createLocalVue()
localVue.use(ElementUI)
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2IconSelect, {
stubs: ['el-popover', 'el-button', 'el-input', 'el-collapse', 'el-collapse-item', 'el-col', 'el-row']
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// // props
// it('has props', () => {
// const wrapper = mount(D2IconSelect, {
// propsData: {
// value: 'value',
// placeholder: '请选择',
// placement: 'right',
// clearable: true,
// userInput: false,
// autoClose: false
// }
// })
// expect(wrapper.props().value).toEqual('value')
// expect(wrapper.props().placeholder).toEqual('请选择')
// expect(wrapper.props().placement).toEqual('right')
// expect(wrapper.props().clearable).toEqual(true)
// expect(wrapper.props().userInput).toEqual(false)
// expect(wrapper.props().autoClose).toEqual(false)
// })
})
+27
View File
@@ -0,0 +1,27 @@
import { mount } from '@vue/test-utils'
import D2IconSvg from '@/components/d2-icon-svg/index.vue'
describe('d2-icon-svg', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2IconSvg, {
propsData: {
name: 'add'
}
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2IconSvg, {
propsData: {
name: 'add'
}
})
expect(wrapper.props().name).toEqual('add')
})
})
+31
View File
@@ -0,0 +1,31 @@
import { mount } from '@vue/test-utils'
import D2Icon from '@/components/d2-icon/index.vue'
describe('d2-icon', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2Icon)
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2Icon)
expect(wrapper.is('.fa')).toBeTruthy()
expect(wrapper.contains('.fa-font-awesome')).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2Icon, {
propsData: {
name: 'font-awesome'
}
})
expect(wrapper.props().name).toEqual('font-awesome')
})
})
+30
View File
@@ -0,0 +1,30 @@
import { mount } from '@vue/test-utils'
import D2LinkBtn from '@/components/d2-link-btn/index.vue'
describe('d2-link-btn', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2LinkBtn, {
stubs: ['el-button-group', 'el-button', 'd2-icon']
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2LinkBtn, {
stubs: ['el-button-group', 'el-button', 'd2-icon'],
propsData: {
title: 'title',
icon: 'icon',
link: 'link'
}
})
expect(wrapper.props().title).toEqual('title')
expect(wrapper.props().icon).toEqual('icon')
expect(wrapper.props().link).toEqual('link')
})
})
+30
View File
@@ -0,0 +1,30 @@
import { mount } from '@vue/test-utils'
import D2ModuleIndexBanner from '@/components/d2-module-index-banner/index.vue'
describe('d2-module-index-banner', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ModuleIndexBanner, {
stubs: ['d2-icon']
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// props
it('has props', () => {
const wrapper = mount(D2ModuleIndexBanner, {
stubs: ['d2-icon'],
propsData: {
title: 'title',
subTitle: 'subTitle',
link: 'link'
}
})
expect(wrapper.props().title).toEqual('title')
expect(wrapper.props().subTitle).toEqual('subTitle')
expect(wrapper.props().link).toEqual('link')
})
})
+36
View File
@@ -0,0 +1,36 @@
import { mount } from '@vue/test-utils'
import D2ModuleIndexMenu from '@/components/d2-module-index-menu/index.vue'
import menu from '@/menu/modules/demo-business'
describe('d2-module-index-menu', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2ModuleIndexMenu, {
stubs: ['el-button'],
propsData: {
menu
}
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 300m后正确渲染,包含特定类名
it('contains specific classnames', (done) => {
const wrapper = mount(D2ModuleIndexMenu, {
stubs: ['el-button'],
propsData: {
menu: menu
}
})
setTimeout(() => {
expect(wrapper.is('.d2-module-index-menu')).toBeTruthy()
expect(wrapper.contains('.d2-module-index-menu-group')).toBeTruthy()
expect(wrapper.contains('.d2-module-index-menu-group--title')).toBeTruthy()
expect(wrapper.contains('.d2-module-index-menu-item')).toBeTruthy()
done()
}, 400)
})
})
+41
View File
@@ -0,0 +1,41 @@
import { mount } from '@vue/test-utils'
import D2PageCover from '@/components/d2-page-cover/index.vue'
describe('d2-page-cover', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2PageCover)
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', () => {
const wrapper = mount(D2PageCover, {
slots: {
default: '<div>default</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.is('.d2-page-cover')).toBeTruthy()
expect(wrapper.contains('.d2-page-cover__logo')).toBeTruthy()
expect(wrapper.contains('.d2-page-cover__title')).toBeTruthy()
expect(wrapper.contains('.d2-page-cover__sub-title')).toBeTruthy()
expect(wrapper.contains('.d2-page-cover__build-time')).toBeTruthy()
})
// 渲染slot
it('has one or more slots', () => {
const wrapper = mount(D2PageCover, {
slots: {
default: '<div>default</div>',
footer: '<div>footer</div>'
}
})
expect(wrapper.text()).toMatch('default')
expect(wrapper.text()).toMatch('footer')
})
})
+39
View File
@@ -0,0 +1,39 @@
import { mount, createLocalVue } from '@vue/test-utils'
import D2Source from '@/components/d2-container/components/d2-source.vue'
describe('d2-source', () => {
// 存在且是Vue组件实例
it('is a vue instance', () => {
const wrapper = mount(D2Source, {
stubs: ['d2-icon']
})
expect(wrapper.exists()).toBeTruthy()
expect(wrapper.isVueInstance()).toBeTruthy()
})
// 包含特定类名
it('contains specific classnames', (done) => {
const wrapper = mount(D2Source, {
stubs: ['d2-icon']
})
expect(wrapper.is('.d2-source')).toBeTruthy()
setTimeout(() => {
expect(wrapper.contains('.d2-source--active')).toBeTruthy()
done()
}, 600)
})
// props
it('has props', () => {
const wrapper = mount(D2Source, {
stubs: ['d2-icon'],
propsData: {
filename: ''
}
})
expect(wrapper.props().filename).toEqual('')
})
})