77import { ConfigAggregator , Messages , Org , SfError } from '@salesforce/core' ;
88import { MockTestOrgData , TestContext } from '@salesforce/core/lib/testSetup' ;
99
10- import { expect , config } from 'chai' ;
10+ import { config , expect } from 'chai' ;
1111import { stubPrompter , stubSfCommandUx } from '@salesforce/sf-plugins-core' ;
1212import { SandboxAccessor } from '@salesforce/core/lib/stateAggregator/accessors/sandboxAccessor' ;
1313import { Config } from '@oclif/core' ;
@@ -52,7 +52,7 @@ describe('org:delete', () => {
5252 it ( 'will prompt before attempting to delete' , async ( ) => {
5353 const deleteCommand = new Delete ( [ ] , { } as Config ) ;
5454 deleteCommand . configAggregator = await ConfigAggregator . create ( ) ;
55- $$ . SANDBOX . stub ( deleteCommand . configAggregator , 'getPropertyValue' ) . onSecondCall ( ) . returns ( testOrg . username ) ;
55+ $$ . SANDBOX . stub ( deleteCommand . configAggregator , 'getPropertyValue' ) . onThirdCall ( ) . returns ( testOrg . username ) ;
5656 const res = await deleteCommand . run ( ) ;
5757 expect ( prompterStubs . confirm . calledOnce ) . to . equal ( true ) ;
5858 expect ( prompterStubs . confirm . firstCall . args [ 0 ] ) . to . equal (
@@ -61,6 +61,23 @@ describe('org:delete', () => {
6161 expect ( res ) . to . deep . equal ( { orgId : testOrg . orgId , username : testOrg . username } ) ;
6262 } ) ;
6363
64+ it ( 'will resolve a default alias' , async ( ) => {
65+ const deleteCommand = new Delete ( [ ] , { } as Config ) ;
66+ deleteCommand . configAggregator = await ConfigAggregator . create ( ) ;
67+ await $$ . stubConfig ( { 'target-org' : 'myAlias' } ) ;
68+ $$ . stubAliases ( { myAlias : testOrg . username } ) ;
69+ const getPropertyValueStub = $$ . SANDBOX . stub ( deleteCommand . configAggregator , 'getPropertyValue' )
70+ . onSecondCall ( )
71+ . returns ( 'myAlias' ) ;
72+ const res = await deleteCommand . run ( ) ;
73+ expect ( prompterStubs . confirm . calledOnce ) . to . equal ( true ) ;
74+ expect ( prompterStubs . confirm . firstCall . args [ 0 ] ) . to . equal (
75+ messages . getMessage ( 'confirmDelete' , [ 'scratch' , testOrg . username ] )
76+ ) ;
77+ expect ( getPropertyValueStub . calledTwice ) . to . be . true ;
78+ expect ( res ) . to . deep . equal ( { orgId : testOrg . orgId , username : testOrg . username } ) ;
79+ } ) ;
80+
6481 it ( 'will determine sandbox vs scratch org and delete sandbox' , async ( ) => {
6582 $$ . SANDBOX . stub ( SandboxAccessor . prototype , 'hasFile' ) . resolves ( true ) ;
6683 const res = await Delete . run ( [ '--target-org' , testOrg . username ] ) ;
0 commit comments