Skip to content

Commit 6dfc171

Browse files
test(vue3): add Account view coverage
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent f67cc87 commit 6dfc171

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { describe, expect, it, vi } from 'vitest'
7+
import { mount } from '@vue/test-utils'
8+
9+
import Account from '../../../views/Account/Account.vue'
10+
11+
vi.mock('@nextcloud/l10n', () => ({
12+
translate: vi.fn((_app: string, text: string) => text),
13+
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
14+
t: vi.fn((_app: string, text: string) => text),
15+
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
16+
getLanguage: vi.fn(() => 'en'),
17+
getLocale: vi.fn(() => 'en'),
18+
isRTL: vi.fn(() => false),
19+
}))
20+
21+
vi.mock('@nextcloud/auth', () => ({
22+
getCurrentUser: vi.fn(() => ({
23+
uid: 'ada',
24+
displayName: 'Ada Lovelace',
25+
})),
26+
}))
27+
28+
describe('Account.vue', () => {
29+
function createWrapper() {
30+
return mount(Account, {
31+
global: {
32+
stubs: {
33+
UserImage: {
34+
name: 'UserImage',
35+
props: ['user'],
36+
template: '<div class="user-image-stub">{{ user.displayName }}</div>',
37+
},
38+
ManagePassword: {
39+
name: 'ManagePassword',
40+
template: '<div class="manage-password-stub"></div>',
41+
},
42+
Signatures: {
43+
name: 'Signatures',
44+
template: '<div class="signatures-stub"></div>',
45+
},
46+
Documents: {
47+
name: 'Documents',
48+
template: '<div class="documents-stub"></div>',
49+
},
50+
},
51+
},
52+
})
53+
}
54+
55+
it('renders the current user details and certificate section', () => {
56+
const wrapper = createWrapper()
57+
58+
expect(wrapper.text()).toContain('Details')
59+
expect(wrapper.text()).toContain('Certificate')
60+
expect(wrapper.text()).toContain('Ada Lovelace')
61+
})
62+
63+
it('passes the current user to UserImage', () => {
64+
const wrapper = createWrapper()
65+
const userImage = wrapper.findComponent({ name: 'UserImage' })
66+
67+
expect(userImage.props('user')).toEqual({
68+
uid: 'ada',
69+
displayName: 'Ada Lovelace',
70+
})
71+
})
72+
73+
it('renders the account partial sections', () => {
74+
const wrapper = createWrapper()
75+
76+
expect(wrapper.find('.manage-password-stub').exists()).toBe(true)
77+
expect(wrapper.find('.signatures-stub').exists()).toBe(true)
78+
expect(wrapper.find('.documents-stub').exists()).toBe(true)
79+
})
80+
})

0 commit comments

Comments
 (0)