12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- import { renderComponent } from '#tests/support/components/index.ts'
- import { i18n } from '#shared/i18n.ts'
- import CommonlTranslateRenderer from '../CommonTranslateRenderer.vue'
- const populateTranslationMap = () => {
- const map = new Map([
- [
- 'A example with an %s which can be inside a %s.',
- 'Ein Beispiel mit einem %s, das in einer %s enthalten sein kann.',
- ],
- ['translation', 'Übersetzung'],
- ['FORMAT_DATE', 'dd/mm/yyyy'],
- ['FORMAT_DATETIME', 'dd/mm/yyyy HH:MM:SS'],
- ])
- i18n.setTranslationMap(map)
- }
- describe('CommonlTranslateRenderer.vue', () => {
- beforeEach(() => {
- populateTranslationMap()
- })
- it('renders link in given source string', () => {
- const view = renderComponent(CommonlTranslateRenderer, {
- props: {
- source: 'A example with an %s which can be inside a %s.',
- placeholders: [
- {
- type: 'link',
- props: {
- link: 'https://www.zammad.org',
- class: 'custom-class',
- },
- content: 'Link',
- },
- i18n.t('translation'),
- ],
- },
- router: true,
- })
- const link = view.getByTestId('common-link')
- expect(link).toHaveTextContent('Link')
- expect(link).toHaveClass('custom-class')
- expect(link).toHaveAttribute('href', 'https://www.zammad.org')
- })
- it('renders a common label in given source string', () => {
- const view = renderComponent(CommonlTranslateRenderer, {
- props: {
- source: 'A example with an %s which can be inside a %s.',
- placeholders: [
- {
- type: 'label',
- props: {
- class: 'custom-class',
- },
- content: 'Label',
- },
- i18n.t('translation'),
- ],
- },
- router: true,
- })
- const label = view.getByTestId('common-label')
- expect(label).toHaveTextContent('Label')
- expect(label).toHaveClass('custom-class')
- })
- })
|