Skip to content

Commit 085678b

Browse files
test(vue3): harden SigningProgress l10n mock
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 3a9ded9 commit 085678b

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/tests/components/validation/SigningProgress.spec.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type AxiosMock = {
1313
get: MockedFunction<(url: string) => Promise<{ data: { ocs: { data: unknown } } }>>
1414
}
1515

16-
const t: TranslationFunction = (_app, text, vars) => {
16+
const translateMessage: TranslationFunction = (_app, text, vars) => {
1717
if (vars) {
1818
return text.replace(/{(\w+)}/g, (_m, key) => String(vars[key]))
1919
}
@@ -31,12 +31,21 @@ vi.mock('@nextcloud/axios', () => ({
3131
vi.mock('@nextcloud/router', () => ({
3232
generateOcsUrl: vi.fn((url: string) => url),
3333
}))
34-
vi.mock('@nextcloud/l10n', () => ({
35-
t: vi.fn(t),
36-
translate: vi.fn(t),
37-
translatePlural: vi.fn((app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
38-
isRTL: vi.fn(() => false),
39-
}))
34+
vi.mock('@nextcloud/l10n', () => {
35+
const translate = (_app: string, text: string, vars?: Record<string, unknown>) => {
36+
if (vars) {
37+
return text.replace(/{(\w+)}/g, (_m, key) => String(vars[key]))
38+
}
39+
return text
40+
}
41+
42+
return {
43+
t: vi.fn(translate),
44+
translate: vi.fn(translate),
45+
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
46+
isRTL: vi.fn(() => false),
47+
}
48+
})
4049
vi.mock('../../../utils/fileStatus.js', () => ({
4150
buildStatusMap: vi.fn(() => ({
4251
'0': { label: 'Draft' },
@@ -66,7 +75,7 @@ describe('SigningProgress', () => {
6675
NcIconSvgWrapper: true,
6776
},
6877
mocks: {
69-
t,
78+
t: translateMessage,
7079
},
7180
})
7281
}

0 commit comments

Comments
 (0)