|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2026 LibreSign 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 Signatures from '../../../../views/Account/partials/Signatures.vue' |
| 10 | + |
| 11 | +vi.mock('@nextcloud/l10n', () => ({ |
| 12 | + t: vi.fn((_app: string, text: string) => text), |
| 13 | + translate: vi.fn((_app: string, text: string) => text), |
| 14 | + translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)), |
| 15 | + n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)), |
| 16 | + isRTL: vi.fn(() => false), |
| 17 | + getLanguage: vi.fn(() => 'en'), |
| 18 | + getLocale: vi.fn(() => 'en'), |
| 19 | +})) |
| 20 | + |
| 21 | +vi.mock('@nextcloud/capabilities', () => ({ |
| 22 | + getCapabilities: vi.fn(() => ({ |
| 23 | + libresign: { |
| 24 | + config: { |
| 25 | + 'sign-elements': { |
| 26 | + 'is-available': true, |
| 27 | + 'can-create-signature': true, |
| 28 | + }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + })), |
| 32 | +})) |
| 33 | + |
| 34 | +describe('Signatures.vue', () => { |
| 35 | + it('passes empty-state message and title through named slots', () => { |
| 36 | + const wrapper = mount(Signatures, { |
| 37 | + global: { |
| 38 | + stubs: { |
| 39 | + Signature: { |
| 40 | + template: ` |
| 41 | + <div class="signature-stub"> |
| 42 | + <div class="slot-title"><slot name="title" /></div> |
| 43 | + <div class="slot-empty"><slot name="no-signatures" /></div> |
| 44 | + </div> |
| 45 | + `, |
| 46 | + }, |
| 47 | + }, |
| 48 | + }, |
| 49 | + }) |
| 50 | + |
| 51 | + expect(wrapper.text()).toContain('Your signatures') |
| 52 | + expect(wrapper.find('.slot-title').text()).toContain('Signature') |
| 53 | + expect(wrapper.find('.slot-empty').text()).toContain('No signature, click here to create a new one') |
| 54 | + }) |
| 55 | +}) |
0 commit comments