Skip to content

Commit 07ccac8

Browse files
committed
test: align manage password upload ref spec
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 9be1a6c commit 07ccac8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/tests/views/Account/partials/ManagePassword.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,38 @@ describe('ManagePassword', () => {
7070
expect(wrapper.vm.mdiDelete).toBeTruthy()
7171
expect(wrapper.vm.mdiCertificate).toBeTruthy()
7272
expect(wrapper.vm.mdiFileReplace).toBeTruthy()
73+
expect(wrapper.vm.$options.components.UploadCertificate).toBeTruthy()
74+
expect(wrapper.vm.$options.components.ReadCertificate).toBeTruthy()
75+
})
76+
77+
it('calls UploadCertificate triggerUpload through ref safely', () => {
78+
loadStateMock.mockImplementation((_app: string, key: string, fallback: unknown) => {
79+
if (key === 'certificate_engine') return 'openssl'
80+
if (key === 'config') return { hasSignatureFile: true }
81+
return fallback
82+
})
83+
hasSignatureFileMock.mockReturnValue(true)
84+
85+
const wrapper = mount(ManagePassword as never, {
86+
global: {
87+
stubs: {
88+
NcButton: { template: '<button><slot /><slot name="icon" /></button>' },
89+
NcIconSvgWrapper: { name: 'NcIconSvgWrapper', props: ['path'], template: '<i class="icon" :data-path="path" />' },
90+
CreatePassword: true,
91+
ReadCertificate: true,
92+
ResetPassword: true,
93+
UploadCertificate: true,
94+
},
95+
},
96+
})
97+
98+
const triggerUpload = vi.fn()
99+
wrapper.vm.$options.methods.triggerUploadCertificate.call({
100+
$refs: {
101+
uploadCertificate: { triggerUpload },
102+
},
103+
})
104+
105+
expect(triggerUpload).toHaveBeenCalledTimes(1)
73106
})
74107
})

0 commit comments

Comments
 (0)