test(Tabbar): modify test case with route mode (#9924)

This commit is contained in:
chenjiangui 2021-11-24 15:10:36 +08:00 committed by GitHub
parent c91be41922
commit cb6c10cd32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View File

@ -10,7 +10,7 @@ exports[`placeholder prop 1`] = `
exports[`route mode 1`] = ` exports[`route mode 1`] = `
<div class="van-hairline--top-bottom van-tabbar van-tabbar--fixed"> <div class="van-hairline--top-bottom van-tabbar van-tabbar--fixed">
<div class="van-tabbar-item van-tabbar-item--active"> <div class="van-tabbar-item">
<div class="van-tabbar-item__icon"> <div class="van-tabbar-item__icon">
<!----> <!---->
</div> </div>

View File

@ -1,15 +1,25 @@
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import { mount, later, mockGetBoundingClientRect } from '../../../test'; import { later, mockGetBoundingClientRect, mount } from '../../../test';
import Vue from 'vue'; import Vue from 'vue';
import Tabbar from '..'; import Tabbar from '..';
import { createLocalVue } from '@vue/test-utils';
Vue.use(VueRouter); Vue.use(VueRouter);
test('route mode', async () => { test('route mode', async () => {
const router = new VueRouter(); const router = new VueRouter({
const wrapper = mount({ routes: [
router, { path: '/', component: { render: () => '/' } },
template: ` { path: '/search', component: { render: () => '/search' } },
{ path: '/star', component: { render: () => '/star' } },
],
});
const localVue = createLocalVue();
localVue.use(VueRouter);
const wrapper = mount(
{
template: `
<van-tabbar route> <van-tabbar route>
<van-tabbar-item replace to="/"> <van-tabbar-item replace to="/">
Tab Tab
@ -25,7 +35,9 @@ test('route mode', async () => {
</van-tabbar-item> </van-tabbar-item>
</van-tabbar> </van-tabbar>
`, `,
}); },
{ localVue, router }
);
expect(wrapper).toMatchSnapshot(); expect(wrapper).toMatchSnapshot();