Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a "global entropy" test for --help #230

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"description": "cli and tui for interacting with the entropy protocol",
"type": "module",
"scripts": {
"start": "yarn build && npm install -g && entropy",
"start": "yarn build:global && entropy",
"start:debug": "DEBUG=@entropyxyz/cli yarn start",
"build": "tsup",
"test": "yarn test:types && yarn test:ts && yarn test:only",
"build:global": "tsup && npm install -g",
"lint": "eslint . --ext .ts --fix",
"test": "yarn test:types && yarn build:global && yarn test:ts && yarn test:only",
"test:only": "./dev/bin/test-only.sh",
"test:ts": "yarn removedb && ./dev/bin/test-ts.sh",
"test:types": "tsc --project tsconfig.json",
Expand Down
14 changes: 14 additions & 0 deletions tests/global.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from 'tape'

import {
promiseRunner,
execPromise
} from './testing-utils'

test('Global: entropy --help', async (t) => {
/* Setup */
const run = promiseRunner(t)

await run('should run the global entropy --help', execPromise('entropy --help'))
t.end()
})
16 changes: 16 additions & 0 deletions tests/testing-utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { exec } from 'node:child_process'
// @ts-ignore
import { spinNetworkUp, spinNetworkDown, } from "@entropyxyz/sdk/testing"
import * as readline from 'readline'
Expand All @@ -11,6 +12,21 @@ export {
export * from './constants'
export * from './setup-test'

/* Promise wrapper function of [exec](https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback)
*
* @param {string} command - a string command to run in child process
*/

export function execPromise (command: string): Promise<any> {
return new Promise((res, rej) => {
exec(command, (error, stdout, stderr) => {
if (!error && !stderr) res(stdout)
else if (!!stderr && !error) rej(stderr)
else if (!!error) rej(error)
})
})
}

/* Helper for wrapping promises which makes it super clear in logging if the promise
* resolves or threw.
*
Expand Down
Loading