@@ -8,6 +8,7 @@ import * as vscode from 'vscode';
88import * as chai from 'chai' ;
99import * as sinonChai from 'sinon-chai' ;
1010import * as sinon from 'sinon' ;
11+ import { ChildProcess } from 'child_process' ;
1112import { TestItem } from './testOSItem' ;
1213import { OdoImpl , ContextType } from '../../../src/odo' ;
1314import { Command } from "../../../src/odo/command" ;
@@ -19,6 +20,7 @@ import OpenShiftItem from '../../../src/openshift/openshiftItem';
1920import pq = require( 'proxyquire' ) ;
2021import globby = require( 'globby' ) ;
2122
23+
2224const { expect} = chai ;
2325chai . use ( sinonChai ) ;
2426
@@ -43,6 +45,7 @@ suite('OpenShift/Component', () => {
4345 let Component : any ;
4446 let fetchTag : sinon . SinonStub ;
4547 let commandStub : sinon . SinonStub ;
48+ let spawnStub : sinon . SinonStub ;
4649
4750 setup ( ( ) => {
4851 sandbox = sinon . createSandbox ( ) ;
@@ -51,6 +54,7 @@ suite('OpenShift/Component', () => {
5154 Component = pq ( '../../../src/openshift/component' , { } ) . Component ;
5255 termStub = sandbox . stub ( OdoImpl . prototype , 'executeInTerminal' ) ;
5356 execStub = sandbox . stub ( OdoImpl . prototype , 'execute' ) . resolves ( { stdout : "" } ) ;
57+ spawnStub = sandbox . stub ( OdoImpl . prototype , 'spawn' ) ;
5458 sandbox . stub ( OdoImpl . prototype , 'getServices' ) ;
5559 sandbox . stub ( OdoImpl . prototype , 'getProjects' ) . resolves ( [ ] ) ;
5660 sandbox . stub ( OdoImpl . prototype , 'getApplications' ) . resolves ( [ ] ) ;
@@ -1122,15 +1126,17 @@ suite('OpenShift/Component', () => {
11221126 } ) ;
11231127
11241128 test ( 'calls the correct odo command w/ context' , async ( ) => {
1129+ const cpStub = { on : sinon . stub ( ) } as any as ChildProcess ;
1130+ spawnStub . resolves ( cpStub ) ;
11251131 await Component . watch ( componentItem ) ;
1126-
1127- expect ( termStub ) . calledOnceWith ( Command . watchComponent ( projectItem . getName ( ) , appItem . getName ( ) , componentItem . getName ( ) ) ) ;
1132+ expect ( spawnStub ) . calledOnceWith ( Command . watchComponent ( projectItem . getName ( ) , appItem . getName ( ) , componentItem . getName ( ) ) ) ;
11281133 } ) ;
11291134
11301135 test ( 'calls the correct odo command w/o context' , async ( ) => {
1136+ const cpStub = { on : sinon . stub ( ) } as any as ChildProcess ;
1137+ spawnStub . resolves ( cpStub ) ;
11311138 await Component . watch ( null ) ;
1132-
1133- expect ( termStub ) . calledOnceWith ( Command . watchComponent ( projectItem . getName ( ) , appItem . getName ( ) , componentItem . getName ( ) ) ) ;
1139+ expect ( spawnStub ) . calledOnceWith ( Command . watchComponent ( projectItem . getName ( ) , appItem . getName ( ) , componentItem . getName ( ) ) ) ;
11341140 } ) ;
11351141 } ) ;
11361142
0 commit comments