Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
VTag improvements (#3975)
Olga Bulatd47d1c0d6a59
diff --git a/frontend/src/components/VMediaInfo/VMediaTags.vue b/frontend/src/components/VMediaInfo/VMediaTags.vueindex 30e8b41c7..e680f4431 100644--- a/frontend/src/components/VMediaInfo/VMediaTags.vue+++ b/frontend/src/components/VMediaInfo/VMediaTags.vue@@ -7,7 +7,7 @@:class="heightClass"><li v-for="tag in visibleTags" :key="tag">- <VTag :href="localizedTagPath(tag)" :title="tag" />+ <VTag :href="localizedTagPath(tag)">{{ tag }}</VTag></li></ul><VButtondiff --git a/frontend/src/components/VTag/VTag.vue b/frontend/src/components/VTag/VTag.vueindex d676f6e4b..e9484e71b 100644--- a/frontend/src/components/VTag/VTag.vue+++ b/frontend/src/components/VTag/VTag.vue@@ -4,9 +4,10 @@size="small"variant="filled-gray"class="label-bold"- :href="href"- >{{ title }}</VButton- >+ v-bind="$props"+ v-on="$listeners"+ ><slot+ /></VButton></template><script lang="ts">@@ -18,10 +19,6 @@ export default defineComponent({name: "VTag",components: { VButton },props: {- title: {- type: String,- required: true,- },href: {type: String,required: true,diff --git a/frontend/test/unit/specs/components/VTag/v-tag.spec.js b/frontend/test/unit/specs/components/VTag/v-tag.spec.jsnew file mode 100644index 000000000..6335c1b04--- /dev/null+++ b/frontend/test/unit/specs/components/VTag/v-tag.spec.js@@ -0,0 +1,31 @@+import { screen } from "@testing-library/vue"++import { render } from "~~/test/unit/test-utils/render"++import VTag from "~/components/VTag/VTag.vue"++describe("VTag", () => {+ let options = {}++ beforeEach(() => {+ options = {+ props: { href: "https://example.com/" },+ slots: { default: "Hello" },+ }+ })++ it("should render an anchor tag by default", () => {+ const { getByRole } = render(VTag, options)+ const link = getByRole("link", { name: "Hello" })+ expect(link).toBeDefined()+ expect(link.href).toEqual("https://example.com/")+ })++ it("renders slot content", () => {+ const slotText = "Slot test"+ options.slots = { default: `<div>${slotText}</div>` }++ render(VTag, options)+ expect(screen.getByText(slotText)).toBeDefined()+ })+})