79 lines
2.2 KiB
JavaScript
79 lines
2.2 KiB
JavaScript
import VnBreadcrumbs from 'src/components/common/VnBreadcrumbs.vue';
|
|
import { createRouter, createMemoryHistory } from 'vue-router';
|
|
describe('<VnBreadcrumbs />', () => {
|
|
const routes = [
|
|
{
|
|
path: '/',
|
|
name: 'Home',
|
|
meta: { title: 'Home' },
|
|
},
|
|
{
|
|
path: '/dashboard',
|
|
name: 'Dashboard',
|
|
meta: { title: 'Dashboard' },
|
|
children: [
|
|
{
|
|
path: 'settings',
|
|
name: 'Settings',
|
|
meta: { title: 'Settings' },
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
const mountComponent = (initialRoute = '/') => {
|
|
const router = createRouter({
|
|
history: createMemoryHistory(),
|
|
routes,
|
|
});
|
|
|
|
router.push(initialRoute);
|
|
return router.isReady().then(() => {
|
|
cy.createWrapper(VnBreadcrumbs, {
|
|
global: {
|
|
plugins: [router],
|
|
},
|
|
});
|
|
});
|
|
};
|
|
|
|
it('renderiza correctamente el componente', () => {
|
|
mountComponent();
|
|
cy.get('.breadcrumbs').should('exist');
|
|
});
|
|
|
|
it('muestra correctamente el breadcrumb en la ruta raíz', () => {
|
|
mountComponent('/');
|
|
cy.get('.breadcrumbs').contains('Home').should('exist');
|
|
});
|
|
|
|
it('muestra correctamente los breadcrumbs en una ruta anidada', () => {
|
|
mountComponent('/dashboard/settings');
|
|
cy.get('.breadcrumbs').contains('Dashboard').should('exist');
|
|
cy.get('.breadcrumbs').contains('Settings').should('exist');
|
|
});
|
|
|
|
it('no muestra breadcrumbs si la ruta no tiene meta', () => {
|
|
const routesWithoutMeta = [
|
|
{
|
|
path: '/nometa',
|
|
name: 'NoMeta',
|
|
},
|
|
];
|
|
const router = createRouter({
|
|
history: createMemoryHistory(),
|
|
routes: routesWithoutMeta,
|
|
});
|
|
|
|
router.push('/nometa');
|
|
router.isReady().then(() => {
|
|
mount(VnBreadcrumbs, {
|
|
global: {
|
|
plugins: [router, Quasar],
|
|
},
|
|
});
|
|
cy.get('.breadcrumbs').should('not.exist');
|
|
});
|
|
});
|
|
});
|