-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALL-9118 - Upgrade Node, NPM and other libraries
tests sonar refactoring
- Loading branch information
1 parent
d02f245
commit 2529d93
Showing
1 changed file
with
11 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,26 @@ | ||
import { describe, expect } from '@jest/globals' | ||
import { exec } from 'child_process' | ||
import { spawnSync } from 'child_process' | ||
|
||
function runCommand(cmd: string, callback: (error: Error | null, stdout: string, stderr: string) => void): void { | ||
exec(cmd, (error, stdout, stderr) => { | ||
callback(error, stdout, stderr) | ||
}) | ||
function runCommand(cmd: string, args: string[]): string { | ||
const result = spawnSync(cmd, args, { shell: false, encoding: 'utf-8' }) | ||
return result.output.toString() | ||
} | ||
|
||
describe('Generic Commands Tests', () => { | ||
it('should display help when no parameter is provided', done => { | ||
runCommand('yarn start', (error, stdout, stderr) => { | ||
expect(stderr).toBe('') | ||
expect(stdout).toContain('Tatum KMS - Key Management System for Tatum-powered apps.') | ||
expect(stdout).toContain('Usage') | ||
done() | ||
}) | ||
it('should display help when no parameter is provided', async () => { | ||
const result = runCommand('yarn', ['start']) | ||
expect(result).toContain('Tatum KMS - Key Management System for Tatum-powered apps.') | ||
expect(result).toContain('Usage') | ||
}) | ||
}) | ||
|
||
const chains: [string][] = [['ABC'], ['XYZ']] | ||
|
||
describe('Chain-specific Commands Tests', () => { | ||
chains.forEach(([chain]) => { | ||
it(`should not generate wallet for ${chain} and end up with error`, done => { | ||
runCommand(`yarn start generatewallet ${chain}`, (error, stdout, stderr) => { | ||
expect(stderr).toContain('Error: Unsupported blockchain') | ||
done() | ||
}) | ||
it(`should not generate wallet for ${chain} and end up with error`, async () => { | ||
const result = runCommand('yarn', ['start', 'generatewallet', `${chain}`]) | ||
expect(result).toContain('Error: Unsupported blockchain.') | ||
}) | ||
}) | ||
}) |