generated from nhcarrigan/template
feat: run vitest on non-component files (#35)
### Explanation This gives us coverage for all of our non-rendering logic, so we can use Playwright E2E testing for the actual components. ### Issue _No response_ ### Attestations - [x] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/) - [x] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/). - [x] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/). ### Dependencies - [x] I have pinned the dependencies to a specific patch version. ### Style - [x] I have run the linter and resolved any errors. - [x] My pull request uses an appropriate title, matching the conventional commit standards. - [x] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request. ### Tests - [x] My contribution adds new code, and I have added tests to cover it. - [x] My contribution modifies existing code, and I have updated the tests to reflect these changes. - [x] All new and existing tests pass locally with my changes. - [x] Code coverage remains at or above the configured threshold. ### Documentation _No response_ ### Versioning Major - My pull request introduces a breaking change. Reviewed-on: https://codeberg.org/nhcarrigan/portfolio/pulls/35 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Art } from "../../src/config/Art";
|
||||
|
||||
describe("art objects", () => {
|
||||
it("should have unique names", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Art.map((a) => {
|
||||
return a.name;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Art.length);
|
||||
});
|
||||
|
||||
it("should have unique img properties", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Art.map((a) => {
|
||||
return a.img;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Art.length);
|
||||
});
|
||||
|
||||
it("should have alt text", () => {
|
||||
expect.assertions(1);
|
||||
const noText = Art.filter((a) => {
|
||||
return a.alt.length === 0;
|
||||
});
|
||||
expect(noText, "found missing alt").toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Certifications } from "../../src/config/Certifications";
|
||||
|
||||
describe("certification objects", () => {
|
||||
it("should have unique names", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Certifications.map((c) => {
|
||||
return c.name;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Certifications.length);
|
||||
});
|
||||
|
||||
it("should have unique file names", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Certifications.map((c) => {
|
||||
return c.fileName;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Certifications.length);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Games } from "../../src/config/Games";
|
||||
|
||||
describe("games objects", () => {
|
||||
it("should have unique names", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Games.map((g) => {
|
||||
return g.name;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Games.length);
|
||||
});
|
||||
|
||||
it("should have unique img properties", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Games.map((g) => {
|
||||
return g.img;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Games.length);
|
||||
});
|
||||
|
||||
it("should have unique urls", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Games.map((g) => {
|
||||
return g.url;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Games.length);
|
||||
});
|
||||
|
||||
it("should have alt text", () => {
|
||||
expect.assertions(1);
|
||||
const noText = Games.filter((g) => {
|
||||
return g.alt.length === 0;
|
||||
});
|
||||
expect(noText, "found missing alt").toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Jobs } from "../../src/config/Jobs";
|
||||
|
||||
describe("jobs objects", () => {
|
||||
it("should have correct start dates", () => {
|
||||
expect.hasAssertions();
|
||||
for (const job of Jobs.slice(1)) {
|
||||
expect(job.start.getDate(), `${job.title} has bad start`).toBe(5);
|
||||
}
|
||||
});
|
||||
|
||||
it("should have correct end dates", () => {
|
||||
expect.hasAssertions();
|
||||
for (const job of Jobs.slice(1)) {
|
||||
if (!job.end) {
|
||||
continue;
|
||||
}
|
||||
expect(job.end.getDate(), `${job.title} has bad end`).toBe(5);
|
||||
}
|
||||
});
|
||||
|
||||
it("should have no future start dates", () => {
|
||||
expect.hasAssertions();
|
||||
expect(Jobs.filter((job) => {
|
||||
return job.start > new Date();
|
||||
}), "have future start dates").toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @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-]+$/);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Partners } from "../../src/config/Partners";
|
||||
|
||||
describe("partner objects", () => {
|
||||
it("should have unique names", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Partners.map((p) => {
|
||||
return p.name;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Partners.length);
|
||||
});
|
||||
|
||||
it("should have unique avatars", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Partners.map((p) => {
|
||||
return p.avatar;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Partners.length);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { faBriefcase, faMoneyBill } from "@fortawesome/free-solid-svg-icons";
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { HireMe, Donate, Socials } from "../../src/config/Socials";
|
||||
|
||||
describe("socials objects", () => {
|
||||
it("should have unique labels", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Socials.map((s) => {
|
||||
return s.label;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Socials.length);
|
||||
});
|
||||
|
||||
it("should have unique links", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Socials.map((s) => {
|
||||
return s.link;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Socials.length);
|
||||
});
|
||||
|
||||
it("should have unique icons", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Socials.map((s) => {
|
||||
return s.icon;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Socials.length);
|
||||
});
|
||||
});
|
||||
|
||||
describe("hire me object", () => {
|
||||
it("should have correct label", () => {
|
||||
expect.assertions(1);
|
||||
expect(HireMe.label, "does not").toBe("Hire Us!");
|
||||
});
|
||||
|
||||
it("should have correct link", () => {
|
||||
expect.assertions(1);
|
||||
expect(HireMe.link, "does not").
|
||||
toBe("https://docs.nhcarrigan.com/about/hire/");
|
||||
});
|
||||
|
||||
it("should have correct colours", () => {
|
||||
expect.assertions(2);
|
||||
expect(HireMe.color, "colour is wrong").toBe("#003600");
|
||||
expect(HireMe.background, "background is wrong").toBe(`linear-gradient(
|
||||
90deg,
|
||||
#5bcefa,
|
||||
#f5a9b8,
|
||||
#ffffff,
|
||||
#f5a9b8,
|
||||
#5bcefa
|
||||
)`);
|
||||
});
|
||||
|
||||
it("should have correct icon", () => {
|
||||
expect.assertions(1);
|
||||
expect(HireMe.icon, "does not").toBe(faBriefcase);
|
||||
});
|
||||
});
|
||||
|
||||
describe("donate object", () => {
|
||||
it("should have correct label", () => {
|
||||
expect.assertions(1);
|
||||
expect(Donate.label, "does not").toBe("Donate 💜");
|
||||
});
|
||||
|
||||
it("should have correct link", () => {
|
||||
expect.assertions(1);
|
||||
expect(Donate.link, "does not").
|
||||
toBe("https://docs.nhcarrigan.com/about/donate/");
|
||||
});
|
||||
|
||||
it("should have correct colours", () => {
|
||||
expect.assertions(2);
|
||||
expect(Donate.color, "has wrong colour").toBe("#003600");
|
||||
expect(Donate.background, "has wrong background").toBe(`linear-gradient(
|
||||
90deg,
|
||||
rgba(255, 0, 0, 1) 0%,
|
||||
rgba(251, 7, 217, 1) 10%,
|
||||
rgba(186, 12, 248, 1) 20%,
|
||||
rgba(95, 21, 242, 1) 30%,
|
||||
rgba(28, 127, 238, 1) 40%,
|
||||
rgba(47, 201, 226, 1) 50%,
|
||||
rgba(63, 218, 216, 1) 60%,
|
||||
rgba(79, 220, 74, 1) 70%,
|
||||
rgba(208, 222, 33, 1) 80%,
|
||||
rgba(255, 154, 0, 1) 90%,
|
||||
rgba(255, 0, 0, 1) 100%
|
||||
)`);
|
||||
});
|
||||
|
||||
it("should have correct icon", () => {
|
||||
expect.assertions(1);
|
||||
expect(Donate.icon, "does not").toBe(faMoneyBill);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { TeamMembers } from "../../src/config/TeamMembers";
|
||||
|
||||
describe("partner objects", () => {
|
||||
it("should have unique names", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
TeamMembers.map((t) => {
|
||||
return t.name;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(TeamMembers.length);
|
||||
});
|
||||
|
||||
it("should have unique avatars", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
TeamMembers.map((t) => {
|
||||
return t.avatar;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(TeamMembers.length);
|
||||
});
|
||||
|
||||
it("should have no future dates", () => {
|
||||
expect.assertions(1);
|
||||
expect(TeamMembers.filter((t) => {
|
||||
return new Date(t.joinDate) > new Date();
|
||||
}), "have future dates").toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Testimonials } from "../../src/config/Testimonials";
|
||||
|
||||
describe("testimonial objects", () => {
|
||||
it("should have unique names", () => {
|
||||
expect.assertions(1);
|
||||
const set = new Set(
|
||||
Testimonials.map((t) => {
|
||||
return t.name;
|
||||
}),
|
||||
);
|
||||
expect(set, "are not unique").toHaveLength(Testimonials.length);
|
||||
});
|
||||
|
||||
it("should have no future dates", () => {
|
||||
expect.assertions(1);
|
||||
expect(Testimonials.filter((t) => {
|
||||
return new Date(t.date) > new Date();
|
||||
}), "have future dates").toHaveLength(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user