From a538a60bcc0cb3c6d51f858c09aab208c7d0e3fe Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Wed, 23 Oct 2024 15:02:33 -0700 Subject: [PATCH] test: verify output --- packages/fast-usdc/package.json | 5 + packages/fast-usdc/test/cli.test.ts | 15 +++ .../fast-usdc/test/snapshots/cli.test.ts.md | 22 ++++ .../fast-usdc/test/snapshots/cli.test.ts.snap | Bin 0 -> 330 bytes yarn.lock | 98 ++++++++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 packages/fast-usdc/test/cli.test.ts create mode 100644 packages/fast-usdc/test/snapshots/cli.test.ts.md create mode 100644 packages/fast-usdc/test/snapshots/cli.test.ts.snap diff --git a/packages/fast-usdc/package.json b/packages/fast-usdc/package.json index 66870ff8210f..9a155649d083 100644 --- a/packages/fast-usdc/package.json +++ b/packages/fast-usdc/package.json @@ -24,6 +24,7 @@ "devDependencies": { "ava": "^5.3.0", "c8": "^9.1.0", + "execa": "^9.4.1", "ts-blank-space": "^0.4.1" }, "dependencies": { @@ -31,6 +32,10 @@ "commander": "^12.1.0" }, "ava": { + "extensions": { + "js": true, + "ts": "module" + }, "files": [ "test/**/*.test.*" ], diff --git a/packages/fast-usdc/test/cli.test.ts b/packages/fast-usdc/test/cli.test.ts new file mode 100644 index 000000000000..9fd1f7f2f27b --- /dev/null +++ b/packages/fast-usdc/test/cli.test.ts @@ -0,0 +1,15 @@ +import test from 'ava'; +import { execa } from 'execa'; +import { fileURLToPath } from 'url'; +import { dirname, join } from 'path'; + +const dir = dirname(fileURLToPath(import.meta.url)); +const CLI_PATH = join(dir, '../src/cli.js'); + +test('CLI shows help when run without arguments', async t => { + const { stderr } = await execa('node', [CLI_PATH], { + reject: false, + }); + + t.snapshot(stderr); +}); diff --git a/packages/fast-usdc/test/snapshots/cli.test.ts.md b/packages/fast-usdc/test/snapshots/cli.test.ts.md new file mode 100644 index 000000000000..53793a2bfaeb --- /dev/null +++ b/packages/fast-usdc/test/snapshots/cli.test.ts.md @@ -0,0 +1,22 @@ +# Snapshot report for `test/cli.test.ts` + +The actual snapshot is saved in `cli.test.ts.snap`. + +Generated by [AVA](https://avajs.dev). + +## CLI shows help when run without arguments + +> Snapshot 1 + + `Usage: fast-usdc [options] [command]␊ + ␊ + CLI to interact with Fast USDC liquidity pool␊ + ␊ + Options:␊ + -V, --version output the version number␊ + -h, --help display help for command␊ + ␊ + Commands:␊ + deposit Offer assets to the liquidity pool␊ + withdraw Withdraw assets from the liquidity pool␊ + help [command] display help for command` diff --git a/packages/fast-usdc/test/snapshots/cli.test.ts.snap b/packages/fast-usdc/test/snapshots/cli.test.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..397afea876248894de338f3b8dbe5776372a4675 GIT binary patch literal 330 zcmV-Q0k!@?RzVK6 zs7Vhm`X7r300000000AZkikyFFc3sj5JK{eKbR{L`GH=8kdTmiKm}D*4{q$#7Kzt* z*MuJXDdkI1(uM1)W2^V4mJKDGft0FFhcUs}NbCiZ7ENOlG_w^RpogemfEWvyr2EPA cI^EB{CQ