GF-12-breadcrumbs #11
1 changed files with 40 additions and 0 deletions
40
tests/stores/breadcrumbs.test.ts
Normal file
40
tests/stores/breadcrumbs.test.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import { createPinia, setActivePinia } from "pinia";
|
||||||
|
import { useBreadcrumbStore } from "~/stores/breadcrumbs";
|
||||||
|
|
||||||
|
vi.unmock("~/stores/breadcrumbs");
|
||||||
|
|
||||||
|
describe("useBreadcrumbStore", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setActivePinia(createPinia());
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("init", () => {
|
||||||
|
it("should initialize", () => {
|
||||||
|
const store = useBreadcrumbStore();
|
||||||
|
expect(store.items.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("clear should remove all breadcrumbs", () => {
|
||||||
|
const store = useBreadcrumbStore();
|
||||||
|
store.addBreadcrumb({ label: "Test", to: "/test" });
|
||||||
|
store.clear();
|
||||||
|
expect(store.items.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("addBreadcrumb should add a breadcrumb", () => {
|
||||||
|
const store = useBreadcrumbStore();
|
||||||
|
store.addBreadcrumb({ label: "Test", to: "/test" });
|
||||||
|
expect(store.items.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("setBreadcrumbs should set breadcrumbs", () => {
|
||||||
|
const store = useBreadcrumbStore();
|
||||||
|
store.setBreadcrumbs([
|
||||||
|
{ label: "Test", to: "/test" },
|
||||||
|
{ label: "Test 2", to: "/test2" },
|
||||||
|
]);
|
||||||
|
expect(store.items.length).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue