@@ -157,4 +157,39 @@ describe('Sandbox Create', () => {
157157 LicenseType : sbxLicenseType ,
158158 } ) ;
159159 } ) ;
160+
161+ it ( 'should have correct output written to stdout' , async ( ) => {
162+ const sbxName = 'createSbx3' ;
163+ const sbxLicenseType = 'Developer' ;
164+ const sbxProcess = getSandboxProcess ( { SandboxName : sbxName } ) ;
165+ const expectedCmdResponse = { ...sbxProcess , SandboxUsername : `${ hubOrgUsername } .${ sbxName } ` } ;
166+ const connection = await stubProdOrgConnection ( sinonSandbox , hubOrgUsername ) ;
167+
168+ const toolingCreateStub = stubToolingCreate ( { sinonSandbox, connection } ) ;
169+ const toolingQueryStub = stubToolingQuery ( { sinonSandbox, connection, sandboxProcessSoql, sbxProcess } ) ;
170+
171+ const result = await CreateSandbox . run ( [ '--name' , sbxName , '-o' , hubOrgUsername , '--async' , '--no-prompt' ] ) ;
172+
173+ expect ( result ) . to . deep . equal ( expectedCmdResponse ) ;
174+ expect ( toolingCreateStub . calledOnce , 'toolingCreateStub' ) . to . be . true ;
175+ expect ( toolingCreateStub . firstCall . args [ 1 ] ) . to . deep . equal ( {
176+ SandboxName : sbxName ,
177+ LicenseType : sbxLicenseType ,
178+ } ) ;
179+ expect ( toolingQueryStub . calledOnce , 'toolingQueryStub' ) . to . be . true ;
180+
181+ // check the sandbox cache entry
182+ const cache = readSandboxCacheFile ( cacheFilePath ) ;
183+ expect ( cache ) . to . have . property ( sbxName ) ;
184+ expect ( cache [ sbxName ] ) . to . have . property ( 'action' , 'Create' ) ;
185+ expect ( cache [ sbxName ] ) . to . have . property ( 'prodOrgUsername' , hubOrgUsername ) ;
186+ expect ( cache [ sbxName ] ) . to . have . deep . property ( 'sandboxProcessObject' , sbxProcess ) ;
187+ expect ( cache [ sbxName ] ) . to . have . deep . property ( 'sandboxRequest' , {
188+ SandboxName : sbxName ,
189+ LicenseType : sbxLicenseType ,
190+ } ) ;
191+ expect ( sfCommandUxStubs ) . to . be . ok ;
192+ const expectedInfoMsg = `org resume sandbox --job-id ${ sbxProcess . Id } -o ${ hubOrgUsername } ` ;
193+ expect ( sfCommandUxStubs . info . firstCall . firstArg ) . to . include ( expectedInfoMsg ) ;
194+ } ) ;
160195} ) ;
0 commit comments