UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

34 lines 1.55 kB
// SPDX-License-Identifier: Apache-2.0 import 'sinon-chai'; import sinon from 'sinon'; import { expect } from 'chai'; import { describe, it, beforeEach, afterEach } from 'mocha'; import { NpmClient } from '../../../../src/integration/npm/npm-client.js'; import { ShellRunner } from '../../../../src/core/shell-runner.js'; describe('NpmClient', () => { let npmClient; let shellRunnerRunStub; beforeEach(() => { npmClient = new NpmClient(); shellRunnerRunStub = sinon.stub(ShellRunner.prototype, 'run'); }); afterEach(() => sinon.restore()); describe('listGlobal', () => { it('should call npm list with global and depth=0 flags', async () => { shellRunnerRunStub.resolves([]); await npmClient.listGlobal(); expect(shellRunnerRunStub).to.have.been.calledOnceWith('npm list --global --depth=0'); }); it('should return the lines from npm list output', async () => { const expectedLines = ['/usr/local/lib', '├── @hashgraph/solo@0.61.0', '└── npm@10.9.2']; shellRunnerRunStub.resolves(expectedLines); const result = await npmClient.listGlobal(); expect(result).to.deep.equal(expectedLines); }); it('should propagate errors thrown by ShellRunner', async () => { shellRunnerRunStub.rejects(new Error('npm not found')); await expect(npmClient.listGlobal()).to.be.rejectedWith('npm not found'); }); }); }); //# sourceMappingURL=npm-client.test.js.map