Skip to content

Commit

Permalink
test: vitest unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilR8 committed Nov 22, 2024
1 parent 55a83f0 commit c829117
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ import { describe, it, expect } from "vitest";
import SelectedSubjectChip from "./SelectedSubjectChip.vue";

describe("SelectedSubjectChip", () => {
it("gets the correct Button Text classes", () => {
const parent1 = "subjects";
expect(SelectedSubjectChip.getButtonTextClasses(parent1)).toStrictEqual(
{
"subjects-li__button-text--sidebar": true,
}
);

const parent2 = "search";
expect(SelectedSubjectChip.getButtonTextClasses(parent2)).toStrictEqual(
{
"subjects-li__button-text--sidebar": false,
}
);
});

it("returns the correct display count", () => {
const subject1 = {
count: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<script>
const getButtonTextClasses = (parent) => {
return {
"subjects-li__button-text--sidebar": parent === "subjects",
};
};
const getCount = (subject) => {
if (subject.count) {
return subject.count;
Expand All @@ -21,6 +27,7 @@ const getDisplayCount = (subject) => {
};
export default {
getButtonTextClasses,
getCount,
getDisplayCount,
};
Expand All @@ -40,9 +47,7 @@ const props = defineProps({
const parent = inject("parent");
const buttonTextClasses = computed(() => ({
"subjects-li__button-text--sidebar": parent === "subjects",
}));
const buttonTextClasses = computed(() => getButtonTextClasses(parent));
</script>
<template>
Expand Down

0 comments on commit c829117

Please sign in to comment.