portfolio/test/config/NavItems.spec.ts

31 lines
806 B
TypeScript
Raw Normal View History

/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { describe, it, expect } from "vitest";
import { NavItems } from "../../src/config/NavItems";
describe("nav items", () => {
it("should be unique", () => {
expect.assertions(2);
const href = new Set(
NavItems.map((n) => {
return n.href;
}),
);
const text = new Set(NavItems.map((n) => {
return n.text;
}));
expect(href, "links are not unique").toHaveLength(NavItems.length);
expect(text, "names are not unique").toHaveLength(NavItems.length);
});
it("should be internal links", () => {
expect.hasAssertions();
for (const nav of NavItems) {
expect(nav.href, `${nav.href} is not internal`).toMatch(/^\/[\da-z-]+$/);
}
});
});