@@ -12,7 +12,7 @@ jest.mock('../../src/lib/deploy-utils');
1212
1313const mockDeployment = { id : 'id0' } ;
1414
15- const { ENVIRONMENT_NAME , REQUIRES_APPROVAL } = options ;
15+ const { ENVIRONMENT_NAME , REQUIRES_APPROVAL , SKIP_STATE_REFRESH } = options ;
1616
1717describe ( 'destroy' , ( ) => {
1818 beforeEach ( ( ) => {
@@ -35,11 +35,11 @@ describe('destroy', () => {
3535
3636 await destroy ( { } ) ;
3737
38- expect ( mockDestroyEnvironment ) . toBeCalledWith ( mockEnvironment ) ;
38+ expect ( mockDestroyEnvironment ) . toHaveBeenCalledWith ( mockEnvironment , expect . anything ( ) ) ;
3939 expect ( mockPollDeploymentStatus ) . toBeCalledWith ( mockDeployment ) ;
4040 } ) ;
4141
42- it ( ' should fail when environment doesnt exist' , async ( ) => {
42+ it ( " should fail when environment doesn't exist" , async ( ) => {
4343 const mockEnvironmentName = 'environment0' ;
4444 mockGetEnvironment . mockResolvedValue ( undefined ) ;
4545
@@ -49,6 +49,21 @@ describe('destroy', () => {
4949 ) ;
5050 } ) ;
5151
52+ describe ( 'skipStateRefresh argument' , ( ) => {
53+ it . each `
54+ options
55+ ${ { [ SKIP_STATE_REFRESH ] : 'true' } }
56+ ${ { [ SKIP_STATE_REFRESH ] : 'false' } }
57+ ${ { } }
58+ ` ( 'should call destroyEnvironment with skipStateRefresh Option, options=$options' , async ( { options } ) => {
59+ const mockEnvironment = { id : 'something' , name : 'someone' } ;
60+ mockGetEnvironment . mockResolvedValue ( mockEnvironment ) ;
61+
62+ await destroy ( options ) ;
63+ expect ( mockDestroyEnvironment ) . toBeCalledWith ( expect . anything ( ) , options ) ;
64+ } ) ;
65+ } ) ;
66+
5267 describe ( 'requires approval argument' , ( ) => {
5368 it . each `
5469 option | existing
@@ -74,7 +89,7 @@ describe('destroy', () => {
7489
7590 await destroy ( { [ REQUIRES_APPROVAL ] : option } ) ;
7691
77- expect ( mockUpdateEnvironment ) . toBeCalledWith ( expect . anything ( ) , { requiresApproval : expected } ) ;
92+ expect ( mockUpdateEnvironment ) . toBeCalledWith ( expect . anything ( ) , { [ REQUIRES_APPROVAL ] : expected } ) ;
7893 } ) ;
7994 } ) ;
8095} ) ;
0 commit comments