@@ -25,15 +25,15 @@ describe('addRegionCommand', function () {
25
25
DBClusterMembers : [ { IsClusterWriter : true } ] ,
26
26
}
27
27
let docdb : DocumentDBClient
28
- let node : DBClusterNode | DBGlobalClusterNode
29
- let sandbox : sinon . SinonSandbox
28
+ let testNode : DBClusterNode | DBGlobalClusterNode
29
+ let sinonSandbox : sinon . SinonSandbox
30
30
let spyExecuteCommand : sinon . SinonSpy
31
31
32
32
beforeEach ( function ( ) {
33
- sandbox = sinon . createSandbox ( )
34
- spyExecuteCommand = sandbox . spy ( vscode . commands , 'executeCommand' )
35
- sandbox . stub ( globals . regionProvider , 'isServiceInRegion' ) . returns ( true )
36
- sandbox . stub ( globals . regionProvider , 'getRegions' ) . returns ( [
33
+ sinonSandbox = sinon . createSandbox ( )
34
+ spyExecuteCommand = sinonSandbox . spy ( vscode . commands , 'executeCommand' )
35
+ sinonSandbox . stub ( globals . regionProvider , 'isServiceInRegion' ) . returns ( true )
36
+ sinonSandbox . stub ( globals . regionProvider , 'getRegions' ) . returns ( [
37
37
{ id : 'us-test-1' , name : 'Test Region 1' } ,
38
38
{ id : 'us-test-2' , name : 'Test Region 2' } ,
39
39
] )
@@ -44,34 +44,34 @@ describe('addRegionCommand', function () {
44
44
. stub ( )
45
45
. resolves ( [ { DBInstanceClass : 'db.r5.large' , StorageType : DBStorageType . Standard } ] )
46
46
47
- sandbox . stub ( DefaultDocumentDBClient , 'create' ) . returns ( docdb )
47
+ sinonSandbox . stub ( DefaultDocumentDBClient , 'create' ) . returns ( docdb )
48
48
49
49
cluster . DBClusterMembers = [ { IsClusterWriter : true } ]
50
50
const parentNode = new DocumentDBNode ( docdb )
51
- node = new DBClusterNode ( parentNode , cluster , docdb )
52
- } )
53
51
52
+ testNode = new DBClusterNode ( parentNode , cluster , docdb )
53
+ } )
54
54
afterEach ( function ( ) {
55
- sandbox . restore ( )
55
+ sinonSandbox . restore ( )
56
56
getTestWindow ( ) . dispose ( )
57
57
} )
58
-
59
58
function setupWizard ( ) {
60
59
getTestWindow ( ) . onDidShowInputBox ( ( input ) => {
61
- let value : string
60
+ let val : string
61
+
62
62
if ( input . prompt ?. includes ( 'global' ) ) {
63
- value = globalClusterName
63
+ val = globalClusterName
64
64
} else if ( input . prompt ?. includes ( 'cluster name' ) ) {
65
- value = clusterName
65
+ val = clusterName
66
66
} else {
67
- value = ''
67
+ val = ''
68
68
}
69
- input . acceptValue ( value )
69
+ input . acceptValue ( val )
70
70
} )
71
71
72
- getTestWindow ( ) . onDidShowQuickPick ( async ( picker ) => {
73
- await picker . untilReady ( )
74
- picker . acceptItem ( picker . items [ 0 ] )
72
+ getTestWindow ( ) . onDidShowQuickPick ( async ( testQuickPicker ) => {
73
+ await testQuickPicker . untilReady ( )
74
+ testQuickPicker . acceptItem ( testQuickPicker . items [ 0 ] )
75
75
} )
76
76
}
77
77
@@ -83,14 +83,15 @@ describe('addRegionCommand', function () {
83
83
const createClusterStub = sinon . stub ( ) . resolves ( {
84
84
DBClusterIdentifier : clusterName ,
85
85
} )
86
- const createInstanceStub = sinon . stub ( ) . resolves ( )
86
+ const createInstanceSinonStub = sinon . stub ( ) . resolves ( )
87
87
docdb . createGlobalCluster = createGlobalClusterStub
88
88
docdb . createCluster = createClusterStub
89
- docdb . createInstance = createInstanceStub
89
+ docdb . createInstance = createInstanceSinonStub
90
+
90
91
setupWizard ( )
91
92
92
93
// act
93
- await addRegion ( node )
94
+ await addRegion ( testNode )
94
95
95
96
// assert
96
97
getTestWindow ( ) . getFirstMessage ( ) . assertInfo ( 'Region added' )
@@ -110,9 +111,8 @@ describe('addRegionCommand', function () {
110
111
} )
111
112
)
112
113
)
113
-
114
114
assert (
115
- createInstanceStub . calledOnceWith (
115
+ createInstanceSinonStub . calledOnceWith (
116
116
sinon . match ( {
117
117
Engine : 'docdb' ,
118
118
DBClusterIdentifier : clusterName ,
@@ -122,7 +122,7 @@ describe('addRegionCommand', function () {
122
122
)
123
123
)
124
124
125
- sandbox . assert . calledWith ( spyExecuteCommand , 'aws.refreshAwsExplorerNode' , node . parent )
125
+ sinonSandbox . assert . calledWith ( spyExecuteCommand , 'aws.refreshAwsExplorerNode' , testNode . parent )
126
126
127
127
assertTelemetry ( 'docdb_addRegion' , { result : 'Succeeded' } )
128
128
} )
@@ -132,12 +132,12 @@ describe('addRegionCommand', function () {
132
132
const createGlobalClusterStub = sinon . stub ( ) . resolves ( {
133
133
GlobalClusterIdentifier : globalClusterName ,
134
134
} )
135
- const createClusterStub = sinon . stub ( ) . resolves ( {
135
+ const createClusterSinonStub = sinon . stub ( ) . resolves ( {
136
136
DBClusterIdentifier : clusterName ,
137
137
} )
138
138
const createInstanceStub = sinon . stub ( ) . resolves ( )
139
139
docdb . createGlobalCluster = createGlobalClusterStub
140
- docdb . createCluster = createClusterStub
140
+ docdb . createCluster = createClusterSinonStub
141
141
docdb . createInstance = createInstanceStub
142
142
setupWizard ( )
143
143
@@ -146,18 +146,18 @@ describe('addRegionCommand', function () {
146
146
GlobalClusterMembers : [ ] ,
147
147
Status : 'available' ,
148
148
}
149
- node = new DBGlobalClusterNode ( new DocumentDBNode ( docdb ) , globalCluster , new Map ( ) , docdb )
149
+ testNode = new DBGlobalClusterNode ( new DocumentDBNode ( docdb ) , globalCluster , new Map ( ) , docdb )
150
150
151
151
// act
152
- await addRegion ( node )
152
+ await addRegion ( testNode )
153
153
154
154
// assert
155
155
getTestWindow ( ) . getFirstMessage ( ) . assertInfo ( 'Region added' )
156
156
157
157
assert ( createGlobalClusterStub . notCalled )
158
158
159
159
assert (
160
- createClusterStub . calledOnceWith (
160
+ createClusterSinonStub . calledOnceWith (
161
161
sinon . match ( {
162
162
DBClusterIdentifier : clusterName ,
163
163
GlobalClusterIdentifier : globalClusterName ,
@@ -175,8 +175,7 @@ describe('addRegionCommand', function () {
175
175
} )
176
176
)
177
177
)
178
-
179
- sandbox . assert . calledWith ( spyExecuteCommand , 'aws.refreshAwsExplorerNode' , node )
178
+ sinonSandbox . assert . calledWith ( spyExecuteCommand , 'aws.refreshAwsExplorerNode' , testNode )
180
179
181
180
assertTelemetry ( 'docdb_addRegion' , { result : 'Succeeded' } )
182
181
} )
@@ -188,7 +187,7 @@ describe('addRegionCommand', function () {
188
187
getTestWindow ( ) . onDidShowQuickPick ( ( input ) => input . hide ( ) )
189
188
190
189
// act
191
- await assert . rejects ( addRegion ( node ) )
190
+ await assert . rejects ( addRegion ( testNode ) )
192
191
193
192
// assert
194
193
assert ( stub . notCalled )
@@ -205,7 +204,7 @@ describe('addRegionCommand', function () {
205
204
setupWizard ( )
206
205
207
206
// act
208
- await assert . rejects ( addRegion ( node ) )
207
+ await assert . rejects ( addRegion ( testNode ) )
209
208
210
209
// assert
211
210
getTestWindow ( )
@@ -217,12 +216,12 @@ describe('addRegionCommand', function () {
217
216
218
217
it ( 'shows a warning when the cluster has no instances' , async function ( ) {
219
218
// arrange
220
- const clusterNode = node as DBClusterNode
219
+ const clusterNode = testNode as DBClusterNode
221
220
clusterNode . cluster . DBClusterMembers = [ ]
222
221
setupWizard ( )
223
222
224
223
// act
225
- await assert . rejects ( addRegion ( node ) )
224
+ await assert . rejects ( addRegion ( testNode ) )
226
225
227
226
// assert
228
227
getTestWindow ( )
@@ -234,12 +233,12 @@ describe('addRegionCommand', function () {
234
233
235
234
it ( 'shows a warning when the cluster has an unsupported instance class' , async function ( ) {
236
235
// arrange
237
- const clusterNode = node as DBClusterNode
236
+ const clusterNode = testNode as DBClusterNode
238
237
clusterNode . instances = [ { DBInstanceClass : 'db.t3.medium' } ]
239
238
setupWizard ( )
240
239
241
240
// act
242
- await assert . rejects ( addRegion ( node ) )
241
+ await assert . rejects ( addRegion ( testNode ) )
243
242
244
243
// assert
245
244
getTestWindow ( )
0 commit comments