From 9d6a7db9429298aaee8e0ad86c6ca3346b2b457c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= Date: Wed, 12 Jul 2023 12:23:55 +0800 Subject: [PATCH] test(checkbox): increase coverage (#1258) * test(checkbox): increase coverage * submit * cover * change * fix * fix test * fix test * fix test --- packages/checkbox/checkbox.test.mts | 52 +++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/packages/checkbox/checkbox.test.mts b/packages/checkbox/checkbox.test.mts index 528a84bfa..43cbf337d 100644 --- a/packages/checkbox/checkbox.test.mts +++ b/packages/checkbox/checkbox.test.mts @@ -400,7 +400,55 @@ describe('checkbox prompt', () => { await expect(answer).resolves.not.toContain(unselect); }); - it('allow disabling help tip', async () => {}); + it('allow disabling help tip', async () => { + const { answer, events, getScreen } = await render(checkbox, { + message: 'Select a number', + choices: numberedChoices, + instructions: false, + }); + + expect(getScreen()).toMatchInlineSnapshot(` + "? Select a number + ❯◯ 1 + ◯ 2 + ◯ 3 + ◯ 4 + ◯ 5 + ◯ 6 + ◯ 7 + (Move up and down to reveal more choices)" + `); + + events.keypress('enter'); + expect(getScreen()).toMatchInlineSnapshot('"? Select a number"'); + + await expect(answer).resolves.toEqual([]); + }); - it('allow customizing help tip', async () => {}); + it('allow customizing help tip', async () => { + const { answer, events, getScreen } = await render(checkbox, { + message: 'Select a number', + choices: numberedChoices, + instructions: + ' (Pulse para seleccionar, para alternar todos, para invertir selección, y para continuar)', + }); + + expect(getScreen()).toMatchInlineSnapshot(` + "? Select a number (Pulse para seleccionar, para alternar todos, + para invertir selección, y para continuar) + ❯◯ 1 + ◯ 2 + ◯ 3 + ◯ 4 + ◯ 5 + ◯ 6 + ◯ 7 + (Move up and down to reveal more choices)" + `); + + events.keypress('enter'); + expect(getScreen()).toMatchInlineSnapshot('"? Select a number"'); + + await expect(answer).resolves.toEqual([]); + }); });