UNPKG

@kadena/kadena-cli

Version:

Kadena CLI tool to interact with the Kadena blockchain (manage keys, transactions, etc.)

45 lines 2.63 kB
import path from 'path'; import { describe, expect, it } from 'vitest'; import { WORKING_DIRECTORY } from '../../../constants/config.js'; import { services } from '../../../services/index.js'; import { mockPrompts, runCommand } from '../../../utils/test.util.js'; describe('add network command', () => { const networkPath = path.join(WORKING_DIRECTORY, '.kadena/networks'); it('should add a "test-network"', async () => { mockPrompts({ input: { 'Enter a network name (e.g. "mainnet")': 'test-network', 'Enter a network id (e.g. "mainnet01")': 'testnet', 'Enter Kadena network host (e.g. "https://api.chainweb.com")': 'http://localhost:30000', 'Enter Kadena network explorer URL (e.g. "https://explorer.chainweb.com/mainnet/tx/")': 'http://localhost:30000/explorer', }, select: { 'Are you sure you want to save this configuration for network "test-network"?': 'yes', }, }); await runCommand('network add'); const networksFilePath = path.join(networkPath, 'test-network.yaml'); expect(await services.filesystem.fileExists(networksFilePath)).toBe(true); }); it('should not add a network when user doesnt want to save the configuration', async () => { mockPrompts({ input: { 'Enter a network name (e.g. "mainnet")': 'no-save-network', 'Enter a network id (e.g. "mainnet01")': 'testnet', 'Enter Kadena network host (e.g. "https://api.chainweb.com")': 'http://localhost:30000', 'Enter Kadena network explorer URL (e.g. "https://explorer.chainweb.com/mainnet/tx/")': 'http://localhost:30000/explorer', }, select: { 'Are you sure you want to save this configuration for network "no-save-network"?': 'no', }, }); const networksFilePath = path.join(networkPath, 'no-save-network.yaml'); expect(await services.filesystem.fileExists(networksFilePath)).toBe(false); }); it('should add a network with all options with --quiet flag', async () => { await runCommand('network add --network-name=test-network-quiet --network-id=development --network-host=http://localhost:8080 --network-explorer-url=http://localhost:8080/explorer --network-overwrite=yes --quiet'); const networksFilePath = path.join(networkPath, 'test-network-quiet.yaml'); expect(await services.filesystem.fileExists(networksFilePath)).toBe(true); }); }); //# sourceMappingURL=networkCreate.test.js.map