Skip to content

Commit f049142

Browse files
test(validation): refactor toggleDetailsAriaLabel tests to it.each
Replace five individual 'it' blocks that each set up a wrapper and assert the same computed property with a single it.each table. Each row is self-describing via the 'description' field shown in the test name ($description). The reactive toggle test is kept separate because it involves sequential state changes. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent a2a609b commit f049142

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,55 @@ describe('SignerDetails.vue - Business Logic', () => {
392392
})
393393
})
394394

395+
describe('toggleDetailsAriaLabel computed', () => {
396+
it.each([
397+
{
398+
description: 'displayName, closed → expand label',
399+
signer: { signed: '2024-06-01T00:00:00Z', displayName: 'Alice' },
400+
initiallyOpen: false,
401+
expected: 'Expand details of Alice',
402+
},
403+
{
404+
description: 'displayName, open → collapse label',
405+
signer: { signed: '2024-06-01T00:00:00Z', displayName: 'Alice' },
406+
initiallyOpen: true,
407+
expected: 'Collapse details of Alice',
408+
},
409+
{
410+
description: 'no displayName → falls back to email',
411+
signer: { signed: '2024-06-01T00:00:00Z', email: 'bob@example.com' },
412+
initiallyOpen: false,
413+
expected: 'Expand details of bob@example.com',
414+
},
415+
{
416+
description: 'no displayName or email → falls back to name',
417+
signer: { signed: '2024-06-01T00:00:00Z', name: 'Charlie' },
418+
initiallyOpen: false,
419+
expected: 'Expand details of Charlie',
420+
},
421+
{
422+
description: 'no identification → falls back to Unknown',
423+
signer: { signed: '2024-06-01T00:00:00Z' },
424+
initiallyOpen: false,
425+
expected: 'Expand details of Unknown',
426+
},
427+
])('$description', ({ signer, initiallyOpen, expected }) => {
428+
wrapper = createWrapper({ signer, initiallyOpen })
429+
expect(wrapper.vm.toggleDetailsAriaLabel).toBe(expected)
430+
})
431+
432+
it('updates reactively when toggleOpen is called', () => {
433+
wrapper = createWrapper({ signer: { signed: '2024-06-01T00:00:00Z', displayName: 'Alice' } })
434+
expect(wrapper.vm.toggleDetailsAriaLabel).toBe('Expand details of Alice')
435+
436+
wrapper.vm.toggleOpen()
437+
expect(wrapper.vm.toggleDetailsAriaLabel).toBe('Collapse details of Alice')
438+
439+
wrapper.vm.toggleOpen()
440+
expect(wrapper.vm.toggleDetailsAriaLabel).toBe('Expand details of Alice')
441+
})
442+
})
443+
395444
describe('toggleOpen method', () => {
396445
it('toggles isOpen when signer has signed', () => {
397446
wrapper = createWrapper({ signer: { signed: '2024-06-01T00:00:00Z' } })

0 commit comments

Comments
 (0)