Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/jl-client into test
This commit is contained in:
commit
a3860cc279
@ -1,11 +1,11 @@
|
|||||||
import { mount, createLocalVue } from '@vue/test-utils'
|
import { mount, createLocalVue } from '@vue/test-utils';
|
||||||
import VueRouter from 'vue-router'
|
import VueRouter from 'vue-router';
|
||||||
import ElementUI from 'element-ui'
|
import ElementUI from 'element-ui';
|
||||||
import Breadcrumb from '@/components/Breadcrumb/index.vue'
|
import Breadcrumb from '@/components/Breadcrumb/index.vue';
|
||||||
|
|
||||||
const localVue = createLocalVue()
|
const localVue = createLocalVue();
|
||||||
localVue.use(VueRouter)
|
localVue.use(VueRouter);
|
||||||
localVue.use(ElementUI)
|
localVue.use(ElementUI);
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
@ -44,37 +44,37 @@ const routes = [
|
|||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
}]
|
}];
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
routes
|
routes
|
||||||
})
|
});
|
||||||
|
|
||||||
describe('Breadcrumb.vue', () => {
|
describe('Breadcrumb.vue', () => {
|
||||||
const wrapper = mount(Breadcrumb, {
|
const wrapper = mount(Breadcrumb, {
|
||||||
localVue,
|
localVue,
|
||||||
router
|
router
|
||||||
})
|
});
|
||||||
it('dashboard', () => {
|
it('dashboard', () => {
|
||||||
router.push('/dashboard')
|
router.push('/dashboard');
|
||||||
const len = wrapper.findAll('.el-breadcrumb__inner').length
|
const len = wrapper.findAll('.el-breadcrumb__inner').length;
|
||||||
expect(len).toBe(1)
|
expect(len).toBe(1);
|
||||||
})
|
});
|
||||||
it('normal route', () => {
|
it('normal route', () => {
|
||||||
router.push('/menu/menu1')
|
router.push('/menu/menu1');
|
||||||
const len = wrapper.findAll('.el-breadcrumb__inner').length
|
const len = wrapper.findAll('.el-breadcrumb__inner').length;
|
||||||
expect(len).toBe(2)
|
expect(len).toBe(2);
|
||||||
})
|
});
|
||||||
it('nested route', () => {
|
it('nested route', () => {
|
||||||
router.push('/menu/menu1/menu1-2/menu1-2-1')
|
router.push('/menu/menu1/menu1-2/menu1-2-1');
|
||||||
const len = wrapper.findAll('.el-breadcrumb__inner').length
|
const len = wrapper.findAll('.el-breadcrumb__inner').length;
|
||||||
expect(len).toBe(4)
|
expect(len).toBe(4);
|
||||||
})
|
});
|
||||||
it('no meta.title', () => {
|
it('no meta.title', () => {
|
||||||
router.push('/menu/menu1/menu1-2/menu1-2-2')
|
router.push('/menu/menu1/menu1-2/menu1-2-2');
|
||||||
const len = wrapper.findAll('.el-breadcrumb__inner').length
|
const len = wrapper.findAll('.el-breadcrumb__inner').length;
|
||||||
expect(len).toBe(3)
|
expect(len).toBe(3);
|
||||||
})
|
});
|
||||||
// it('click link', () => {
|
// it('click link', () => {
|
||||||
// router.push('/menu/menu1/menu1-2/menu1-2-2')
|
// router.push('/menu/menu1/menu1-2/menu1-2-2')
|
||||||
// const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner')
|
// const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner')
|
||||||
@ -90,9 +90,9 @@ describe('Breadcrumb.vue', () => {
|
|||||||
// expect(redirectBreadcrumb.contains('a')).toBe(false)
|
// expect(redirectBreadcrumb.contains('a')).toBe(false)
|
||||||
// })
|
// })
|
||||||
it('last breadcrumb', () => {
|
it('last breadcrumb', () => {
|
||||||
router.push('/menu/menu1/menu1-2/menu1-2-1')
|
router.push('/menu/menu1/menu1-2/menu1-2-1');
|
||||||
const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner')
|
const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner');
|
||||||
const redirectBreadcrumb = breadcrumbArray.at(3)
|
const redirectBreadcrumb = breadcrumbArray.at(3);
|
||||||
expect(redirectBreadcrumb.contains('a')).toBe(false)
|
expect(redirectBreadcrumb.contains('a')).toBe(false);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
import { shallowMount } from '@vue/test-utils'
|
import { shallowMount } from '@vue/test-utils';
|
||||||
import Hamburger from '@/components/Hamburger/index.vue'
|
import Hamburger from '@/components/Hamburger/index.vue';
|
||||||
|
|
||||||
describe('Hamburger.vue', () => {
|
describe('Hamburger.vue', () => {
|
||||||
it('toggle click', () => {
|
it('toggle click', () => {
|
||||||
const wrapper = shallowMount(Hamburger)
|
const wrapper = shallowMount(Hamburger);
|
||||||
const mockFn = jest.fn()
|
const mockFn = jest.fn();
|
||||||
wrapper.vm.$on('toggleClick', mockFn)
|
wrapper.vm.$on('toggleClick', mockFn);
|
||||||
wrapper.find('.hamburger').trigger('click')
|
wrapper.find('.hamburger').trigger('click');
|
||||||
expect(mockFn).toBeCalled()
|
expect(mockFn).toBeCalled();
|
||||||
})
|
});
|
||||||
it('prop isActive', () => {
|
it('prop isActive', () => {
|
||||||
const wrapper = shallowMount(Hamburger)
|
const wrapper = shallowMount(Hamburger);
|
||||||
wrapper.setProps({ isActive: true })
|
wrapper.setProps({ isActive: true });
|
||||||
expect(wrapper.contains('.is-active')).toBe(true)
|
expect(wrapper.contains('.is-active')).toBe(true);
|
||||||
wrapper.setProps({ isActive: false })
|
wrapper.setProps({ isActive: false });
|
||||||
expect(wrapper.contains('.is-active')).toBe(false)
|
expect(wrapper.contains('.is-active')).toBe(false);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
import { shallowMount } from '@vue/test-utils'
|
import { shallowMount } from '@vue/test-utils';
|
||||||
import SvgIcon from '@/components/SvgIcon/index.vue'
|
import SvgIcon from '@/components/SvgIcon/index.vue';
|
||||||
describe('SvgIcon.vue', () => {
|
describe('SvgIcon.vue', () => {
|
||||||
it('iconClass', () => {
|
it('iconClass', () => {
|
||||||
const wrapper = shallowMount(SvgIcon, {
|
const wrapper = shallowMount(SvgIcon, {
|
||||||
propsData: {
|
propsData: {
|
||||||
iconClass: 'test'
|
iconClass: 'test'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
expect(wrapper.find('use').attributes().href).toBe('#icon-test')
|
expect(wrapper.find('use').attributes().href).toBe('#icon-test');
|
||||||
})
|
});
|
||||||
it('className', () => {
|
it('className', () => {
|
||||||
const wrapper = shallowMount(SvgIcon, {
|
const wrapper = shallowMount(SvgIcon, {
|
||||||
propsData: {
|
propsData: {
|
||||||
iconClass: 'test'
|
iconClass: 'test'
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
expect(wrapper.classes().length).toBe(1)
|
expect(wrapper.classes().length).toBe(1);
|
||||||
wrapper.setProps({ className: 'test' })
|
wrapper.setProps({ className: 'test' });
|
||||||
expect(wrapper.classes().includes('test')).toBe(true)
|
expect(wrapper.classes().includes('test')).toBe(true);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user