@@ -12,9 +12,12 @@ import { fromStub, spyMethod, stubInterface, stubMethod } from '@salesforce/ts-s
12
12
import { ConfigFile , Org , SfdxProject } from '@salesforce/core' ;
13
13
import { IConfig } from '@oclif/config' ;
14
14
import { UX } from '@salesforce/command' ;
15
+ import { MetadataApiDeploy } from '@salesforce/source-deploy-retrieve' ;
15
16
import { Report } from '../../../src/commands/force/source/deploy/report' ;
16
17
import { DeployReportResultFormatter } from '../../../src/formatters/deployReportResultFormatter' ;
17
18
import { DeployCommandResult } from '../../../src/formatters/deployResultFormatter' ;
19
+ import { DeployProgressBarFormatter } from '../../../src/formatters/deployProgressBarFormatter' ;
20
+ import { DeployProgressStatusFormatter } from '../../../src/formatters/deployProgressStatusFormatter' ;
18
21
import { getDeployResult } from './deployResponses' ;
19
22
20
23
describe ( 'force:source:report' , ( ) => {
@@ -33,6 +36,7 @@ describe('force:source:report', () => {
33
36
const oclifConfigStub = fromStub ( stubInterface < IConfig > ( sandbox ) ) ;
34
37
let checkDeployStatusStub : sinon . SinonStub ;
35
38
let uxLogStub : sinon . SinonStub ;
39
+ let pollStatusStub : sinon . SinonStub ;
36
40
37
41
class TestReport extends Report {
38
42
public async runIt ( ) {
@@ -45,6 +49,11 @@ describe('force:source:report', () => {
45
49
public setProject ( project : SfdxProject ) {
46
50
this . project = project ;
47
51
}
52
+
53
+ public createDeploy ( ) : MetadataApiDeploy {
54
+ pollStatusStub = sandbox . stub ( MetadataApiDeploy . prototype , 'pollStatus' ) ;
55
+ return MetadataApiDeploy . prototype ;
56
+ }
48
57
}
49
58
50
59
const runReportCmd = async ( params : string [ ] ) => {
@@ -91,9 +100,11 @@ describe('force:source:report', () => {
91
100
} ) ;
92
101
93
102
it ( 'should display stashed deploy ID' , async ( ) => {
103
+ const progressBarStub = sandbox . stub ( DeployProgressBarFormatter . prototype , 'progress' ) . returns ( ) ;
94
104
const result = await runReportCmd ( [ ] ) ;
95
105
expect ( result ) . to . deep . equal ( expectedResults ) ;
96
106
expect ( uxLogStub . firstCall . args [ 0 ] ) . to . contain ( stashedDeployId ) ;
107
+ expect ( progressBarStub . calledOnce ) . to . equal ( true ) ;
97
108
} ) ;
98
109
99
110
it ( 'should use the jobid flag' , async ( ) => {
@@ -105,18 +116,22 @@ describe('force:source:report', () => {
105
116
} ) ;
106
117
107
118
it ( 'should display the jobid flag' , async ( ) => {
119
+ const progressBarStub = sandbox . stub ( DeployProgressBarFormatter . prototype , 'progress' ) . returns ( ) ;
108
120
const result = await runReportCmd ( [ '--jobid' , expectedResults . id ] ) ;
109
121
expect ( result ) . to . deep . equal ( expectedResults ) ;
110
122
expect ( uxLogStub . firstCall . args [ 0 ] ) . to . contain ( expectedResults . id ) ;
123
+ expect ( progressBarStub . calledOnce ) . to . equal ( true ) ;
111
124
} ) ;
112
125
113
126
it ( 'should display output with no --json' , async ( ) => {
114
127
const displayStub = sandbox . stub ( DeployReportResultFormatter . prototype , 'display' ) ;
128
+ const progressBarStub = sandbox . stub ( DeployProgressBarFormatter . prototype , 'progress' ) . returns ( ) ;
115
129
const getJsonStub = sandbox . stub ( DeployReportResultFormatter . prototype , 'getJson' ) ;
116
130
await runReportCmd ( [ ] ) ;
117
131
expect ( displayStub . calledOnce ) . to . equal ( true ) ;
118
132
expect ( getJsonStub . calledOnce ) . to . equal ( true ) ;
119
133
expect ( uxLogStub . called ) . to . equal ( true ) ;
134
+ expect ( progressBarStub . calledOnce ) . to . equal ( true ) ;
120
135
} ) ;
121
136
122
137
it ( 'should NOT display output with --json' , async ( ) => {
@@ -127,4 +142,13 @@ describe('force:source:report', () => {
127
142
expect ( getJsonStub . calledOnce ) . to . equal ( true ) ;
128
143
expect ( uxLogStub . called ) . to . equal ( false ) ;
129
144
} ) ;
145
+
146
+ it ( 'should call the correct progress method' , async ( ) => {
147
+ const progressBarStub = sandbox . stub ( DeployProgressBarFormatter . prototype , 'progress' ) . returns ( ) ;
148
+ const progressStatusStub = sandbox . stub ( DeployProgressStatusFormatter . prototype , 'progress' ) . returns ( ) ;
149
+ await runReportCmd ( [ ] ) ;
150
+ expect ( progressStatusStub . calledOnce ) . to . equal ( false ) ;
151
+ expect ( progressBarStub . calledOnce ) . to . equal ( true ) ;
152
+ expect ( pollStatusStub . calledOnce ) . to . equal ( true ) ;
153
+ } ) ;
130
154
} ) ;
0 commit comments