Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snapshot test for sidebar header layout #406

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { shallowMount } from "@vue/test-utils";
import { describe, expect, it } from "vitest";

import SidebarHeaderLayout from "../../SidebarHeaderLayout.vue";

import type { VueWrapper } from "@vue/test-utils";

describe("SidebarHeaderLayout", () => {
it("matches snapshot", () => {
const wrapper: VueWrapper = shallowMount(SidebarHeaderLayout, {
props: {
menu: [
{
name: "Menu1",
routeName: "menu-1",
shortName: "M1",
},
{
name: "Menu2",
routeName: "menu-2",
shortName: "M2",
},
],
},
slots: {
default: "<div class='default'></div>",
},
});

expect(wrapper.element).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`SidebarHeaderLayout > matches snapshot 1`] = `
<div
class="layout sidebar-header-layout"
>

<app-header-stub
nologo="true"
nomainmenu="true"
/>

<sidebar-stub
class="layout-sidebar"
menu="[object Object],[object Object]"
noheader="false"
/>
<main>

<div
class="default"
/>

</main>
</div>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import configPlugin from "@dzangolab/vue3-config";
import { mount } from "@vue/test-utils";
import { createPinia } from "pinia";
import { describe, expect, it } from "vitest";
import { createRouter, createWebHistory } from "vue-router";

import SidebarHeaderLayout from "../../SidebarHeaderLayout.vue";
import appConfig from "../config";

import type { VueWrapper } from "@vue/test-utils";

describe("SidebarHeaderLayout", () => {
it("matches snapshot", () => {
const pinia = createPinia();
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: "/",
name: "home",
component: SidebarHeaderLayout,
},
],
});

const wrapper: VueWrapper = mount(SidebarHeaderLayout, {
global: {
plugins: [
pinia,
[
configPlugin,
{
config: appConfig,
},
],
router,
],
stubs: {
UserMenu: true,
LocaleSwitcher: true,
},
},
slots: {
afterNavLinks: "<div class='after-nav'></div>",
afterSidebarMenu: "<div class='after-sidebar'></div>",
default: "<div class='default'></div>",
},
});

expect(wrapper.element).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`SidebarHeaderLayout > matches snapshot 1`] = `
<div
class="layout sidebar-header-layout"
>

<header>

<!---->

<nav
data-expanded="false"
>

<!---->




<locale-switcher-stub
class="locales"
/>

</nav>
<div
class="toggle"
>

<svg
aria-hidden="true"
height="1.5rem"
role="img"
viewBox="0 0 16 16"
width="1.5rem"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
/>

</div>
</header>

<div
class="no-sidebar layout-sidebar"
>
<img
alt="show sidebar"
src="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cgk8ZyBzdHJva2Utd2lkdGg9IjAiPgoJPC9nPgoJPGcgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj4KCTwvZz4KCTxnPgoJCTxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOC4yOTI4OSA0LjI5Mjg5QzguNjgzNDIgMy45MDIzNyA5LjMxNjU4IDMuOTAyMzcgOS43MDcxMSA0LjI5Mjg5TDE2LjcwNzEgMTEuMjkyOUMxNy4wOTc2IDExLjY4MzQgMTcuMDk3NiAxMi4zMTY2IDE2LjcwNzEgMTIuNzA3MUw5LjcwNzExIDE5LjcwNzFDOS4zMTY1OCAyMC4wOTc2IDguNjgzNDIgMjAuMDk3NiA4LjI5Mjg5IDE5LjcwNzFDNy45MDIzNyAxOS4zMTY2IDcuOTAyMzcgMTguNjgzNCA4LjI5Mjg5IDE4LjI5MjlMMTQuNTg1OCAxMkw4LjI5Mjg5IDUuNzA3MTFDNy45MDIzNyA1LjMxNjU4IDcuOTAyMzcgNC42ODM0MiA4LjI5Mjg5IDQuMjkyODlaIiBmaWxsPSIjZmZmZmZmIj4KCQk8L3BhdGg+Cgk8L2c+Cjwvc3ZnPgo="
/>
</div>
<main>


<div
class="default"
/>


</main>
</div>
`;
Loading