Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat committed Apr 8, 2024
1 parent d5e9bb2 commit 6e24866
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
6 changes: 4 additions & 2 deletions frontend/src/components/VMediaInfo/VMediaTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import type { Tag } from "~/types/media"
import type { SupportedMediaType } from "~/constants/media"
import { useFeatureFlagStore } from "~/stores/feature-flag"
import { useSearchStore } from "~/stores/search"
import { useI18n } from "~/composables/use-i18n"
import { focusElement } from "~/utils/focus-management"
Expand Down Expand Up @@ -87,7 +88,8 @@ export default defineComponent({
const searchStore = useSearchStore()
const featureFlagStore = useFeatureFlagStore()
const { app, $sendCustomEvent } = useContext()
const { $sendCustomEvent } = useContext()
const i18n = useI18n()
const additionalSearchViews = computed(() =>
featureFlagStore.isOn("additional_search_views")
Expand All @@ -106,7 +108,7 @@ export default defineComponent({
const collapsibleRowsStartAt = ref<number>()
const dir = computed(() => {
return app.i18n.localeProperties.dir
return i18n.localeProperties.dir
})
function isFurtherInline(previous: HTMLElement, current: HTMLElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ describe("AudioTrack", () => {

it("should render the full audio track component even without duration", () => {
options.propsData.layout = "full"
const { getByText } = render(VAudioTrack, options, configureVue)
const creator = getByText(props.audio.creator)
expect(creator).toBeInstanceOf(HTMLAnchorElement)
const { getByRole } = render(VAudioTrack, options, configureVue)
const creator = getByRole("link", { name: props.audio.creator })
expect(creator).toBeVisible()
})

it("should show audio title as main page title in full layout", () => {
Expand All @@ -73,10 +73,13 @@ describe("AudioTrack", () => {

it("should show audio creator in a full layout with link", () => {
options.propsData.layout = "full"
const { getByText } = render(VAudioTrack, options, configureVue)
const element = getByText(props.audio.creator)
expect(element).toBeInstanceOf(HTMLAnchorElement)
expect(element).toHaveAttribute("href", props.audio.creator_url)
const { getByRole } = render(VAudioTrack, options, configureVue)
const element = getByRole("link", { name: props.audio.creator })
expect(element).toBeVisible()
expect(element).toHaveAttribute(
"href",
`/audio/collection?source=jamendo&creator=${props.audio.creator}`
)
})

it("should render the row audio track component even without duration", () => {
Expand Down
4 changes: 3 additions & 1 deletion frontend/test/unit/test-utils/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import VueI18n from "vue-i18n"

const messages = require("~/locales/en.json")

export const i18n = new VueI18n({
const i18n = new VueI18n({
locale: "en",
fallbackLocale: "en",
messages: {
en: messages,
},
})
i18n.localeProperties = { code: "en", dir: "ltr" }
export { i18n }
7 changes: 6 additions & 1 deletion frontend/test/unit/test-utils/pinia.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ export const createPinia = () =>
},
},
error: jest.fn(),
localePath: jest.fn(),
localePath: jest.fn((val) => {
const queryString = Object.keys(val?.query)
.map((key) => key + "=" + val?.query[key])
.join("&")
return `${val?.path ?? "/"}?${queryString}`
}),
},
}))

Expand Down

0 comments on commit 6e24866

Please sign in to comment.