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 { ConfigAggregator , Messages , Org , SfError } from '@salesforce/core' ;
7+ import { Messages , Org , SfError } from '@salesforce/core' ;
88import { MockTestOrgData , TestContext } from '@salesforce/core/lib/testSetup' ;
99
1010import { config , expect } from 'chai' ;
1111import { stubPrompter , stubSfCommandUx } from '@salesforce/sf-plugins-core' ;
1212import { SandboxAccessor } from '@salesforce/core/lib/stateAggregator/accessors/sandboxAccessor' ;
13- import { Config } from '@oclif/core' ;
1413import { Delete } from '../../../../src/commands/force/org/delete' ;
1514
1615config . truncateThreshold = 0 ;
@@ -29,18 +28,14 @@ describe('org:delete', () => {
2928
3029 beforeEach ( async ( ) => {
3130 await $$ . stubAuths ( testOrg , testHub ) ;
32- await $$ . stubConfig ( { 'target-org' : testOrg . username } ) ;
3331 prompterStubs = stubPrompter ( $$ . SANDBOX ) ;
3432 sfCommandUxStubs = stubSfCommandUx ( $$ . SANDBOX ) ;
3533 } ) ;
3634
3735 it ( 'will throw an error when no default set' , async ( ) => {
38- const deleteCommand = new Delete ( [ ] , { } as Config ) ;
39- deleteCommand . configAggregator = await ConfigAggregator . create ( ) ;
40- $$ . SANDBOX . stub ( deleteCommand . configAggregator , 'getPropertyValue' ) . onSecondCall ( ) . returns ( undefined ) ;
41-
36+ await $$ . stubConfig ( { } ) ;
4237 try {
43- await deleteCommand . run ( ) ;
38+ await Delete . run ( ) ;
4439 expect . fail ( 'should have thrown an error' ) ;
4540 } catch ( e ) {
4641 const err = e as SfError ;
@@ -50,10 +45,8 @@ describe('org:delete', () => {
5045 } ) ;
5146
5247 it ( 'will prompt before attempting to delete' , async ( ) => {
53- const deleteCommand = new Delete ( [ ] , { } as Config ) ;
54- deleteCommand . configAggregator = await ConfigAggregator . create ( ) ;
55- $$ . SANDBOX . stub ( deleteCommand . configAggregator , 'getPropertyValue' ) . onThirdCall ( ) . returns ( testOrg . username ) ;
56- const res = await deleteCommand . run ( ) ;
48+ await $$ . stubConfig ( { 'target-org' : testOrg . username } ) ;
49+ const res = await Delete . run ( [ ] ) ;
5750 expect ( prompterStubs . confirm . calledOnce ) . to . equal ( true ) ;
5851 expect ( prompterStubs . confirm . firstCall . args [ 0 ] ) . to . equal (
5952 messages . getMessage ( 'confirmDelete' , [ 'scratch' , testOrg . username ] )
@@ -62,19 +55,13 @@ describe('org:delete', () => {
6255 } ) ;
6356
6457 it ( 'will resolve a default alias' , async ( ) => {
65- const deleteCommand = new Delete ( [ ] , { } as Config ) ;
66- deleteCommand . configAggregator = await ConfigAggregator . create ( ) ;
6758 await $$ . stubConfig ( { 'target-org' : 'myAlias' } ) ;
6859 $$ . stubAliases ( { myAlias : testOrg . username } ) ;
69- const getPropertyValueStub = $$ . SANDBOX . stub ( deleteCommand . configAggregator , 'getPropertyValue' )
70- . onSecondCall ( )
71- . returns ( 'myAlias' ) ;
72- const res = await deleteCommand . run ( ) ;
60+ const res = await Delete . run ( [ ] ) ;
7361 expect ( prompterStubs . confirm . calledOnce ) . to . equal ( true ) ;
7462 expect ( prompterStubs . confirm . firstCall . args [ 0 ] ) . to . equal (
7563 messages . getMessage ( 'confirmDelete' , [ 'scratch' , testOrg . username ] )
7664 ) ;
77- expect ( getPropertyValueStub . calledTwice ) . to . be . true ;
7865 expect ( res ) . to . deep . equal ( { orgId : testOrg . orgId , username : testOrg . username } ) ;
7966 } ) ;
8067
0 commit comments