forked from revoltchat/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintenance: Mobile - Move app-specific code into shared context when…
… it makes sense
- Loading branch information
1 parent
c997733
commit 8d3abca
Showing
16 changed files
with
93 additions
and
75 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
4 changes: 2 additions & 2 deletions
4
app/frontend/apps/mobile/components/CommonStepper/__tests__/CommonStepper.spec.ts
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 was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
app/frontend/apps/mobile/components/CommonStepper/types.ts
This file was deleted.
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
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 |
---|---|---|
@@ -1,63 +1,85 @@ | ||
// Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
import { nextTick } from 'vue' | ||
import { defineComponent, nextTick } from 'vue' | ||
import { renderComponent } from '#tests/support/components/index.ts' | ||
import { i18n } from '#shared/i18n.ts' | ||
import CommonSectionMenu from '#mobile/components/CommonSectionMenu/CommonSectionMenu.vue' // TODO: switch to shared component example | ||
|
||
const Example = defineComponent({ | ||
name: 'Example', | ||
props: { | ||
text: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
data: () => ({ i18n }), | ||
template: '<div>{{ i18n.t(text) }}</div>', | ||
}) | ||
|
||
const populateTranslationMap = () => { | ||
const map = new Map([ | ||
['yes', 'ja'], | ||
['Hello world!', 'Hallo Welt!'], | ||
['The second component.', 'Die zweite Komponente.'], | ||
[ | ||
'String with 3 placeholders: %s %s %s', | ||
'Zeichenkette mit 3 Platzhaltern: %s %s %s', | ||
], | ||
['FORMAT_DATE', 'dd/mm/yyyy'], | ||
['FORMAT_DATETIME', 'dd/mm/yyyy HH:MM:SS'], | ||
]) | ||
|
||
i18n.setTranslationMap(map) | ||
} | ||
|
||
describe('i18n', () => { | ||
afterEach(() => { | ||
i18n.setTranslationMap(new Map()) | ||
}) | ||
|
||
it('starts with empty state', () => { | ||
expect(i18n.t('unknown string')).toBe('unknown string') | ||
expect(i18n.t('yes')).toBe('yes') | ||
}) | ||
|
||
it('translates known strings', () => { | ||
const map = new Map([ | ||
['yes', 'ja'], | ||
['Hello world!', 'Hallo Welt!'], | ||
['The second component.', 'Die zweite Komponente.'], | ||
[ | ||
'String with 3 placeholders: %s %s %s', | ||
'Zeichenkette mit 3 Platzhaltern: %s %s %s', | ||
], | ||
['FORMAT_DATE', 'dd/mm/yyyy'], | ||
['FORMAT_DATETIME', 'dd/mm/yyyy HH:MM:SS'], | ||
]) | ||
describe('i18n populated', () => { | ||
beforeEach(() => { | ||
populateTranslationMap() | ||
}) | ||
|
||
i18n.setTranslationMap(map) | ||
expect(i18n.t('yes')).toBe('ja') | ||
}) | ||
it('handles placeholders correctly', () => { | ||
// No arguments. | ||
expect(i18n.t('String with 3 placeholders: %s %s %s')).toBe( | ||
'Zeichenkette mit 3 Platzhaltern: %s %s %s', | ||
) | ||
}) | ||
it('translates known strings', () => { | ||
expect(i18n.t('yes')).toBe('ja') | ||
}) | ||
|
||
it('translates dates', () => { | ||
expect(i18n.date('2021-04-09T10:11:12Z')).toBe('09/04/2021') | ||
expect(i18n.dateTime('2021-04-09T10:11:12Z')).toBe('09/04/2021 10:11:12') | ||
expect(i18n.relativeDateTime(new Date().toISOString())).toBe('just now') | ||
}) | ||
it('handles placeholders correctly', () => { | ||
// No arguments. | ||
expect(i18n.t('String with 3 placeholders: %s %s %s')).toBe( | ||
'Zeichenkette mit 3 Platzhaltern: %s %s %s', | ||
) | ||
}) | ||
|
||
it('updates (reactive) translations automatically', async () => { | ||
const { container } = renderComponent(CommonSectionMenu, { | ||
props: { | ||
headerLabel: 'Hello world!', | ||
}, | ||
slots: { | ||
default: 'Example Content', | ||
}, | ||
global: { | ||
mocks: { | ||
i18n, | ||
}, | ||
}, | ||
it('translates dates', () => { | ||
expect(i18n.date('2021-04-09T10:11:12Z')).toBe('09/04/2021') | ||
expect(i18n.dateTime('2021-04-09T10:11:12Z')).toBe('09/04/2021 10:11:12') | ||
expect(i18n.relativeDateTime(new Date().toISOString())).toBe('just now') | ||
}) | ||
|
||
expect(container).toHaveTextContent('Hallo Welt!') | ||
i18n.setTranslationMap(new Map()) | ||
await nextTick() | ||
expect(container).toHaveTextContent('Hello world!') | ||
it('updates (reactive) translations automatically', async () => { | ||
const { container } = renderComponent(Example, { | ||
props: { | ||
text: 'Hello world!', | ||
}, | ||
global: { | ||
mocks: { | ||
i18n, | ||
}, | ||
}, | ||
}) | ||
|
||
expect(container).toHaveTextContent('Hallo Welt!') | ||
i18n.setTranslationMap(new Map()) | ||
await nextTick() | ||
expect(container).toHaveTextContent('Hello world!') | ||
}) | ||
}) | ||
}) |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/frontend/shared/router/guards/before/__tests__/permission.spec.ts
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