-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: FelixSjogren <felixarvidsjogren@gmail.com> FEAT - Add lot for the content instead of a prop (#2) Closes #2 Co-authored-by: Stagge <jonatan.stagge@gmail.com> TEST - Add tests for VTag (#7) Added tests for Vtag, tests include: All props are sent to VButton VTag renders slot content Renders anchor tag. Co-authored-by: Stagge <jonatan.stagge@gmail.com> FEAT - Ensure inner VButton emits and handles events in VTag #4 Closes #4 Added accessibility label (#10) - Added aria-label to indicate that that the link is a tag Improvements from review lint Signed-off-by: Olga Bulat <obulat@gmail.com>
- Loading branch information
Showing
3 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
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,50 @@ | ||
import { screen } from "@testing-library/vue" | ||
|
||
import { render } from "~~/test/unit/test-utils/render" | ||
|
||
import VTag from "~/components/VTag/VTag.vue" | ||
|
||
describe("VTag", () => { | ||
let props = null | ||
let options = null | ||
|
||
beforeEach(() => { | ||
props = {} | ||
options = { propsData: props } | ||
}) | ||
|
||
it("should render an anchor tag by default", () => { | ||
options.propsData = { | ||
...options.propsData, | ||
title: "exTitle", | ||
href: "https://example.com/", | ||
} | ||
const { container } = render(VTag, options) | ||
expect(container.firstChild.tagName).toEqual("A") | ||
}) | ||
|
||
it("should pass all props to VButton", () => { | ||
options.propsData = { | ||
...options.propsData, | ||
title: "exTitle", | ||
href: "https://example.com/", | ||
} | ||
const { container } = render(VTag, options) | ||
expect(container.firstChild.title).toEqual("exTitle") | ||
expect(container.firstChild.href).toEqual("https://example.com/") | ||
}) | ||
|
||
it("renders slot content", () => { | ||
const label = "I'm a label" | ||
options.propsData = { | ||
href: "https://example.com/", | ||
title: "Slot test", | ||
} | ||
options.slots = { | ||
default: `<div aria-label="${label}">Hello</div>`, | ||
} | ||
|
||
render(VTag, options) | ||
expect(screen.queryByLabelText(label)).toBeDefined() | ||
}) | ||
}) |