From f7f5f3435316b97529ed80bf456d4ff905ba7a97 Mon Sep 17 00:00:00 2001 From: alin Date: Mon, 21 Oct 2024 14:49:25 +0200 Subject: [PATCH] Add test for --version output --- tests/cli/packages/cli/version.test.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/cli/packages/cli/version.test.js b/tests/cli/packages/cli/version.test.js index 2dd02a39..22183d6e 100644 --- a/tests/cli/packages/cli/version.test.js +++ b/tests/cli/packages/cli/version.test.js @@ -6,10 +6,26 @@ describe('@aedart/cli', () => { describe('version', () => { - it('can display version', () => { + it('has version property', () => { const result = makeCliApplication().version; assert.strictEqual(typeof result, 'string', 'Cli Application does not have version defined'); }); + + it('can display version', async () => { + let buffer = ''; + + const cli = makeCliApplication({ + writeOut: (str) => { + buffer = buffer.concat(str).trim(); + } + }); + + // --------------------------------------------------------------- // + + await cli.run(['--version'], { from: 'user' }); + + assert.strictEqual(buffer, cli.version, 'Version was not displayed in output'); + }); }); }); \ No newline at end of file