@@ -8,6 +8,7 @@ import * as vscode from 'vscode';
8
8
import * as chai from 'chai' ;
9
9
import * as sinonChai from 'sinon-chai' ;
10
10
import * as sinon from 'sinon' ;
11
+ import { ChildProcess } from 'child_process' ;
11
12
import { TestItem } from './testOSItem' ;
12
13
import { OdoImpl , ContextType } from '../../../src/odo' ;
13
14
import { Command } from "../../../src/odo/command" ;
@@ -19,6 +20,7 @@ import OpenShiftItem from '../../../src/openshift/openshiftItem';
19
20
import pq = require( 'proxyquire' ) ;
20
21
import globby = require( 'globby' ) ;
21
22
23
+
22
24
const { expect} = chai ;
23
25
chai . use ( sinonChai ) ;
24
26
@@ -43,6 +45,7 @@ suite('OpenShift/Component', () => {
43
45
let Component : any ;
44
46
let fetchTag : sinon . SinonStub ;
45
47
let commandStub : sinon . SinonStub ;
48
+ let spawnStub : sinon . SinonStub ;
46
49
47
50
setup ( ( ) => {
48
51
sandbox = sinon . createSandbox ( ) ;
@@ -51,6 +54,7 @@ suite('OpenShift/Component', () => {
51
54
Component = pq ( '../../../src/openshift/component' , { } ) . Component ;
52
55
termStub = sandbox . stub ( OdoImpl . prototype , 'executeInTerminal' ) ;
53
56
execStub = sandbox . stub ( OdoImpl . prototype , 'execute' ) . resolves ( { stdout : "" } ) ;
57
+ spawnStub = sandbox . stub ( OdoImpl . prototype , 'spawn' ) ;
54
58
sandbox . stub ( OdoImpl . prototype , 'getServices' ) ;
55
59
sandbox . stub ( OdoImpl . prototype , 'getProjects' ) . resolves ( [ ] ) ;
56
60
sandbox . stub ( OdoImpl . prototype , 'getApplications' ) . resolves ( [ ] ) ;
@@ -1122,15 +1126,17 @@ suite('OpenShift/Component', () => {
1122
1126
} ) ;
1123
1127
1124
1128
test ( 'calls the correct odo command w/ context' , async ( ) => {
1129
+ const cpStub = { on : sinon . stub ( ) } as any as ChildProcess ;
1130
+ spawnStub . resolves ( cpStub ) ;
1125
1131
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 ( ) ) ) ;
1128
1133
} ) ;
1129
1134
1130
1135
test ( 'calls the correct odo command w/o context' , async ( ) => {
1136
+ const cpStub = { on : sinon . stub ( ) } as any as ChildProcess ;
1137
+ spawnStub . resolves ( cpStub ) ;
1131
1138
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 ( ) ) ) ;
1134
1140
} ) ;
1135
1141
} ) ;
1136
1142
0 commit comments