您如何使用router-link
和Jest在Vue中测试vue-test-utils
?
VUE文件
<div class="modal-footer success-modal-headerfooter">
<router-link id="orderBtn" to="/order" tag="button" class="btn btn-success" data-dismiss="modal">
Place another order
</router-link>
<router-link id="reviewBtn" to="/review" tag="button" class="btn btn-info" data-dismiss="modal">
Review existing orders
</router-link>
<router-link id="closeBtn" ref="closeButton" to="/" tag="button" class="btn packnet-btn-primary" data-dismiss="modal">
Close
</router-link>
</div>
routes.js的一部分
import Home from './components/Home.vue';
import Review from './components/Review';
import Order from './components/Order.vue';
export const routes = [
{ path: '', component: Home },
{ path: '/order', component: Order },
{
path: '/review', component: Review, children: [
{ path: '', component: ExistingOrders },
{
path: ':id', component: OrderReport, beforeEnter: (to, from, next) => {
let orderCount = store.getters.orderPaginator.items.filter(item => item.id === +to.params.id).length;
next(orderCount > 0);
}
}
]
}
];
我需要测试每个click
的{{1}},但是如何?