UNPKG

@hashgraph/solo

Version:

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

34 lines 1.6 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 { ShellRunner } from '../../../src/core/shell_runner.js'; import { SoloLogger } from '../../../src/core/logging.js'; import { ChildProcess } from 'child_process'; import { Readable } from 'stream'; import { Duration } from '../../../src/core/time/duration.js'; describe('ShellRunner', () => { let shellRunner, loggerDebugStub, loggerInfoStub, childProcessSpy, readableSpy; beforeEach(() => { shellRunner = new ShellRunner(); // Spy on methods loggerDebugStub = sinon.stub(SoloLogger.prototype, 'debug'); loggerInfoStub = sinon.stub(SoloLogger.prototype, 'info'); childProcessSpy = sinon.spy(ChildProcess.prototype, 'on'); readableSpy = sinon.spy(Readable.prototype, 'on'); }); afterEach(() => sinon.restore()); it('should run command', async () => { await shellRunner.run('ls -l'); loggerInfoStub.withArgs("Executing command: 'ls -l'").onFirstCall(); loggerDebugStub.withArgs("Finished executing: 'ls -l'", sinon.match.any).onFirstCall(); expect(loggerDebugStub).to.have.been.calledOnce; expect(loggerInfoStub).to.have.been.calledOnce; expect(readableSpy).to.have.been.calledWith('data', sinon.match.any); expect(childProcessSpy).to.have.been.calledWith('exit', sinon.match.any); }).timeout(Duration.ofSeconds(10).toMillis()); }); //# sourceMappingURL=shell_runner.test.js.map