@@ -21,17 +21,19 @@ suite('OpenShift/Application', () => {
21
21
let quickPickStub : sinon . SinonStub ;
22
22
let sandbox : sinon . SinonSandbox ;
23
23
let execStub : sinon . SinonStub ;
24
+ let getProjectsStub : sinon . SinonStub ;
24
25
const clusterItem = new TestItem ( null , 'cluster' , ContextType . CLUSTER ) ;
25
26
const projectItem = new TestItem ( clusterItem , 'project' , ContextType . PROJECT ) ;
26
27
const appItem = new TestItem ( projectItem , 'app' , ContextType . APPLICATION ) ;
27
- const compItem = new TestItem ( appItem , 'app ' , ContextType . COMPONENT_NO_CONTEXT , [ ] , null ) ;
28
+ const compItem = new TestItem ( appItem , 'component ' , ContextType . COMPONENT_NO_CONTEXT , [ ] , null ) ;
28
29
compItem . path = 'path/to/component' ;
29
30
appItem . getChildren ( ) . push ( compItem ) ;
30
31
31
32
setup ( ( ) => {
32
33
sandbox = sinon . createSandbox ( ) ;
33
34
execStub = sandbox . stub ( OdoImpl . prototype , 'execute' ) . resolves ( { error : null , stdout : '' , stderr : '' } ) ;
34
35
sandbox . stub ( OdoImpl . prototype , 'getClusters' ) . resolves ( [ clusterItem ] ) ;
36
+ getProjectsStub = sandbox . stub ( OdoImpl . prototype , 'getProjects' ) . resolves ( [ projectItem ] ) ;
35
37
sandbox . stub ( OdoImpl . prototype , 'getApplications' ) . resolves ( [ appItem ] ) ;
36
38
sandbox . stub ( OpenShiftItem , 'getApplicationNames' ) . resolves ( [ appItem ] ) ;
37
39
sandbox . stub ( vscode . window , 'showInputBox' ) ;
@@ -60,7 +62,7 @@ suite('OpenShift/Application', () => {
60
62
suite ( 'called from command palette' , ( ) => {
61
63
62
64
test ( 'calls the appropriate error message when no project found' , async ( ) => {
63
- sandbox . stub ( OdoImpl . prototype , 'getProjects' ) . resolves ( [ ] ) ;
65
+ getProjectsStub . onFirstCall ( ) . resolves ( [ ] ) ;
64
66
try {
65
67
await Application . describe ( null ) ;
66
68
} catch ( err ) {
@@ -72,7 +74,6 @@ suite('OpenShift/Application', () => {
72
74
} ) ;
73
75
74
76
test ( 'asks to select a project and an application' , async ( ) => {
75
- sandbox . stub ( OdoImpl . prototype , 'getProjects' ) . resolves ( [ projectItem ] ) ;
76
77
const apps = [ appItem ] ;
77
78
quickPickStub = sandbox . stub ( vscode . window , 'showQuickPick' ) ;
78
79
quickPickStub . onFirstCall ( ) . resolves ( appItem ) ;
@@ -83,7 +84,6 @@ suite('OpenShift/Application', () => {
83
84
} ) ;
84
85
85
86
test ( 'skips odo command execution if canceled by user' , async ( ) => {
86
- sandbox . stub ( OdoImpl . prototype , 'getProjects' ) . resolves ( [ projectItem ] ) ;
87
87
quickPickStub = sandbox . stub ( vscode . window , 'showQuickPick' ) . resolves ( null ) ;
88
88
await Application . describe ( null ) ;
89
89
expect ( termStub ) . not . called ;
@@ -96,16 +96,17 @@ suite('OpenShift/Application', () => {
96
96
97
97
setup ( ( ) => {
98
98
warnStub = sandbox . stub ( vscode . window , 'showWarningMessage' ) ;
99
- sandbox . stub ( OdoImpl . prototype , 'getProjects' ) . resolves ( [ projectItem ] ) ;
100
- sandbox . stub ( OdoImpl . prototype , 'getComponents' ) . resolves ( [ compItem ] ) ;
99
+ getProjectsStub . onFirstCall ( ) . resolves ( [ projectItem ] ) ;
100
+ const pushedCompItem = new TestItem ( appItem , 'app' , ContextType . COMPONENT_PUSHED , [ ] ) ;
101
+ sandbox . stub ( OdoImpl . prototype , 'getApplicationChildren' ) . resolves ( [ pushedCompItem ] ) ;
101
102
} ) ;
102
103
103
104
test ( 'calls the appropriate odo command if confirmed' , async ( ) => {
104
105
warnStub . resolves ( 'Yes' ) ;
105
106
106
107
await Application . del ( appItem ) ;
107
108
108
- expect ( execStub ) . calledOnceWith ( Command . deleteApplication ( projectItem . getName ( ) , appItem . getName ( ) ) ) ;
109
+ expect ( execStub ) . calledWith ( Command . deleteApplication ( projectItem . getName ( ) , appItem . getName ( ) ) ) ;
109
110
} ) ;
110
111
111
112
test ( 'returns a confirmation message text when successful' , async ( ) => {
0 commit comments