From 1e78d77c4086b5222cc74eb5f1da93613e254dd1 Mon Sep 17 00:00:00 2001 From: "Angel M. Adames" Date: Fri, 1 Mar 2024 14:56:09 -0400 Subject: [PATCH] chore: Add cmd tests --- test/utils/cmd.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/utils/cmd.test.ts diff --git a/test/utils/cmd.test.ts b/test/utils/cmd.test.ts new file mode 100644 index 0000000..24c0c20 --- /dev/null +++ b/test/utils/cmd.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, test } from 'bun:test'; +import cmd from '../../src/utils/cmd'; + +describe('Utils: cmd', () => { + test('runs commands and returns undefined', () => { + expect(cmd.run("cat /dev/null")).toBeUndefined(); + }); + + test('removes extra spaces from multi-line and returns undefined', () => { + expect(cmd.run("cat /dev/null ")).toBeUndefined(); + }); + + test('returns output to stdout', () => { + const output = cmd.runIt("echo 'Hello world!'"); + expect(output.trim()).toEqual('Hello world!'); + }); +});