-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #387 from dmlb/tag-color-units
render fix for tag color and write some unit tests
- Loading branch information
Showing
13 changed files
with
4,560 additions
and
431 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { describe, expect, it } from "vitest" | ||
import { render } from "@testing-library/svelte" | ||
|
||
import TagWrapper from "./TagWrapper.svelte" | ||
import { darkColors, lightColors } from "../resources" | ||
|
||
describe("TagWrapper", () => { | ||
it("renders the style css var for light color hex to --tag-color", () => { | ||
const tagComp = render(TagWrapper, { tagColor: "lavender" }) | ||
const divEl = tagComp.getByTestId("tag-wrapper-component") | ||
|
||
expect(getComputedStyle(divEl).getPropertyValue("--tag-color")).toContain( | ||
lightColors.lavender | ||
) | ||
}) | ||
|
||
it("renders the tag-color class for tag colour match found", () => { | ||
const tagComp = render(TagWrapper, { tagColor: "lavender" }) | ||
const divEl = tagComp.getByTestId("tag-wrapper-component") | ||
|
||
expect(divEl.classList).toContain("tag-color") | ||
}) | ||
|
||
it("renders the style css var for dark color hex to --tag-color-dark", () => { | ||
const tagComp = render(TagWrapper, { tagColor: "lavender" }) | ||
const divEl = tagComp.getByTestId("tag-wrapper-component") | ||
|
||
expect( | ||
getComputedStyle(divEl).getPropertyValue("--tag-color-dark") | ||
).toContain(darkColors.lavender) | ||
}) | ||
|
||
it("does not add the style css var for colour not in the map", () => { | ||
const tagComp = render(TagWrapper, { tagColor: "not-real" }) | ||
const divEl = tagComp.getByTestId("tag-wrapper-component") | ||
|
||
expect(getComputedStyle(divEl).getPropertyValue("--tag-color-dark")).toBe( | ||
"" | ||
) | ||
}) | ||
|
||
it("does not add the tag-color class for colour not in the map", () => { | ||
const tagComp = render(TagWrapper, { tagColor: "not-real" }) | ||
const divEl = tagComp.getByTestId("tag-wrapper-component") | ||
|
||
expect(divEl.classList).not.toContain("tag-color") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.