From 341a69e6e00812a3804b111873e0532c57ec31cc Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Wed, 15 Jun 2022 18:47:06 +0100 Subject: [PATCH] Add e2e test for command help --- .../test/builtin.test.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/e2e/spring-shell-e2e-tests/test/builtin.test.ts b/e2e/spring-shell-e2e-tests/test/builtin.test.ts index e5448b11..e8861456 100644 --- a/e2e/spring-shell-e2e-tests/test/builtin.test.ts +++ b/e2e/spring-shell-e2e-tests/test/builtin.test.ts @@ -32,6 +32,21 @@ describe('builtin commands', () => { await expect(cli.exitCode()).resolves.toBe(0); }; + /** + * test for command help command returns expected info + */ + const commandHelpReturnsInfoDesc = 'command help returns info'; + const commandHelpCommand = ['help help']; + const commandHelpReturnsInfo = async (cli: Cli) => { + cli.run(); + await waitForExpect(async () => { + const screen = cli.screen(); + expect(screen).toEqual(expect.arrayContaining([expect.stringContaining('OPTIONS')])); + expect(screen).not.toEqual(expect.arrayContaining([expect.stringContaining('CURRENTLY UNAVAILABLE')])); + }); + await expect(cli.exitCode()).resolves.toBe(0); + }; + beforeEach(async () => { waitForExpect.defaults.timeout = waitForExpectDefaultTimeout; waitForExpect.defaults.interval = waitForExpectDefaultInterval; @@ -61,6 +76,18 @@ describe('builtin commands', () => { }, testTimeout ); + + it( + commandHelpReturnsInfoDesc, + async () => { + cli = new Cli({ + command: command, + options: [...options, ...commandHelpCommand] + }); + await commandHelpReturnsInfo(cli); + }, + testTimeout + ); }); /** @@ -83,5 +110,17 @@ describe('builtin commands', () => { }, testTimeout ); + + it( + commandHelpReturnsInfoDesc, + async () => { + cli = new Cli({ + command: command, + options: [...options, ...commandHelpCommand] + }); + await commandHelpReturnsInfo(cli); + }, + testTimeout + ); }); });