44 * Licensed under the BSD 3-Clause license.
55 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66 */
7- import { Config , StateAggregator , SfError , Messages , Org , SfProject } from '@salesforce/core' ;
7+ import { SfError , Messages , Org , SfProject } from '@salesforce/core' ;
88import { fromStub , stubInterface , stubMethod } from '@salesforce/ts-sinon' ;
99import * as sinon from 'sinon' ;
1010import { expect } from '@salesforce/command/lib/test' ;
@@ -44,8 +44,6 @@ describe('org:create', () => {
4444 let uxLogStub : sinon . SinonStub ;
4545 let uxWarnStub : sinon . SinonStub ;
4646 let promptStub : sinon . SinonStub ;
47- let aliasGetStub : sinon . SinonStub ;
48- let aliasSetStub : sinon . SinonSpy ;
4947 let cmd : TestCreate ;
5048
5149 class TestCreate extends Create {
@@ -109,6 +107,7 @@ describe('org:create', () => {
109107 const prodOrg = stubMethod ( sandbox , Org . prototype , 'scratchOrgCreate' ) . resolves ( CREATE_RESULT ) ;
110108 await command . runIt ( ) ;
111109 expect ( prodOrg . firstCall . args [ 0 ] ) . to . deep . equal ( {
110+ alias : undefined ,
112111 apiversion : undefined ,
113112 clientSecret : undefined ,
114113 connectedAppConsumerKey : undefined ,
@@ -120,6 +119,8 @@ describe('org:create', () => {
120119 unit : 0 ,
121120 } ,
122121 retry : 0 ,
122+ setDefault : false ,
123+ tracksSource : true ,
123124 definitionfile : 'myScratchDef.json' ,
124125 orgConfig : {
125126 licenseType : 'LicenseFromVarargs' ,
@@ -161,6 +162,7 @@ describe('org:create', () => {
161162 const prodOrg = stubMethod ( sandbox , Org . prototype , 'scratchOrgCreate' ) . resolves ( CREATE_RESULT ) ;
162163 await command . runIt ( ) ;
163164 expect ( prodOrg . firstCall . args [ 0 ] ) . to . deep . equal ( {
165+ alias : undefined ,
164166 apiversion : undefined ,
165167 clientSecret,
166168 connectedAppConsumerKey,
@@ -173,6 +175,8 @@ describe('org:create', () => {
173175 unit : 0 ,
174176 } ,
175177 retry : 0 ,
178+ setDefault : false ,
179+ tracksSource : true ,
176180 orgConfig : { } ,
177181 } ) ;
178182 expect ( promptStub . callCount ) . to . equal ( 1 ) ;
@@ -201,17 +205,9 @@ describe('org:create', () => {
201205 ...CREATE_RESULT ,
202206 username : 'newScratchUsername' ,
203207 } ) ;
204- aliasGetStub = sinon . stub ( ) . returns ( '' ) ;
205- aliasSetStub = sinon . spy ( ) ;
206- stubMethod ( sandbox , StateAggregator , 'getInstance' ) . returns ( {
207- aliases : {
208- get : aliasGetStub ,
209- set : aliasSetStub ,
210- } ,
211- } ) ;
212- const configStub = stubMethod ( sandbox , Config . prototype , 'set' ) ;
213208 await command . runIt ( ) ;
214209 expect ( prodOrg . firstCall . args [ 0 ] ) . to . deep . equal ( {
210+ alias : 'scratchOrgAlias' ,
215211 apiversion : undefined ,
216212 clientSecret : undefined ,
217213 connectedAppConsumerKey : undefined ,
@@ -224,11 +220,10 @@ describe('org:create', () => {
224220 unit : 0 ,
225221 } ,
226222 retry : 0 ,
223+ setDefault : true ,
224+ tracksSource : true ,
227225 orgConfig : { } ,
228226 } ) ;
229- expect ( aliasSetStub . firstCall . args ) . to . deep . equal ( [ 'scratchOrgAlias' , 'newScratchUsername' ] ) ;
230- expect ( aliasGetStub . firstCall . args ) . to . deep . equal ( [ 'newScratchUsername' ] ) ;
231- expect ( configStub . firstCall . args ) . to . deep . equal ( [ 'target-org' , 'newScratchUsername' ] ) ;
232227 } ) ;
233228
234229 it ( 'will set alias as default' , async ( ) => {
@@ -252,18 +247,9 @@ describe('org:create', () => {
252247 username : 'newScratchUsername' ,
253248 } ) ;
254249
255- aliasGetStub = sinon . stub ( ) . returns ( 'scratchOrgAlias' ) ;
256- aliasSetStub = sinon . spy ( ) ;
257- stubMethod ( sandbox , StateAggregator , 'getInstance' ) . returns ( {
258- aliases : {
259- get : aliasGetStub ,
260- set : aliasSetStub ,
261- } ,
262- } ) ;
263-
264- const configStub = stubMethod ( sandbox , Config . prototype , 'set' ) ;
265250 await command . runIt ( ) ;
266251 expect ( prodOrg . firstCall . args [ 0 ] ) . to . deep . equal ( {
252+ alias : 'scratchOrgAlias' ,
267253 apiversion : undefined ,
268254 clientSecret : undefined ,
269255 connectedAppConsumerKey : undefined ,
@@ -277,10 +263,9 @@ describe('org:create', () => {
277263 } ,
278264 retry : 0 ,
279265 orgConfig : { } ,
266+ setDefault : true ,
267+ tracksSource : true ,
280268 } ) ;
281- expect ( aliasSetStub . firstCall . args ) . to . deep . equal ( [ 'scratchOrgAlias' , 'newScratchUsername' ] ) ;
282- expect ( aliasGetStub . firstCall . args ) . to . deep . equal ( [ 'newScratchUsername' ] ) ;
283- expect ( configStub . firstCall . args ) . to . deep . equal ( [ 'target-org' , 'scratchOrgAlias' ] ) ;
284269 } ) ;
285270
286271 it ( 'will test json output' , async ( ) => {
@@ -295,6 +280,7 @@ describe('org:create', () => {
295280 } ) ;
296281 const result = await command . runIt ( ) ;
297282 expect ( prodOrg . firstCall . args [ 0 ] ) . to . deep . equal ( {
283+ alias : undefined ,
298284 apiversion : undefined ,
299285 clientSecret : undefined ,
300286 connectedAppConsumerKey : undefined ,
@@ -307,6 +293,8 @@ describe('org:create', () => {
307293 unit : 0 ,
308294 } ,
309295 retry : 0 ,
296+ tracksSource : true ,
297+ setDefault : false ,
310298 orgConfig : { } ,
311299 } ) ;
312300 expect ( result ) . to . have . keys ( [ 'username' , 'authFields' , 'scratchOrgInfo' , 'warnings' , 'orgId' ] ) ;
0 commit comments