@@ -14,7 +14,11 @@ import { DBInstance, DocumentDBClient } from '../../../shared/clients/docdbClien
1414describe ( 'DBClusterNode' , function ( ) {
1515 let mockClient : DocumentDBClient
1616 beforeEach ( ( ) => {
17- mockClient = { } as DocumentDBClient
17+ mockClient = {
18+ listClusters : sinon . stub ( ) . resolves ( [ ] ) , // Mock implementation
19+ listInstances : sinon . stub ( ) . resolves ( [ ] ) , // Mock implementation
20+ } as Partial < DocumentDBClient > as DocumentDBClient
21+
1822 DBClusterNode [ 'globalPollingArns' ] . clear ( )
1923 } )
2024
@@ -33,7 +37,7 @@ describe('DBClusterNode', function () {
3337 }
3438
3539 it ( 'gets children' , async function ( ) {
36- mockClient . listInstances = sinon . stub ( ) . resolves ( [ instanceA , instanceB ] )
40+ ; ( mockClient . listInstances as sinon . SinonStub ) = sinon . stub ( ) . resolves ( [ instanceA , instanceB ] )
3741 const node = new DBClusterNode ( parentNode , cluster , mockClient )
3842 const [ firstInstanceNode , secondInstanceNode , ...otherNodes ] = await node . getChildren ( )
3943
@@ -44,17 +48,17 @@ describe('DBClusterNode', function () {
4448
4549 it ( 'returns false for available status' , function ( ) {
4650 const clusterStatus = { ...cluster , Status : 'available' }
47- const node = new DBClusterNode ( parentNode , clusterStatus , mockClient )
4851
52+ const node = new DBClusterNode ( parentNode , clusterStatus , mockClient )
4953 const requiresPolling = node . isStatusRequiringPolling ( )
5054
5155 assert . strictEqual ( requiresPolling , false , 'isStatusRequiringPolling should return false for available status' )
5256 } )
5357
5458 it ( 'returns true for creating status' , function ( ) {
5559 const clusterStatus = { ...cluster , Status : 'creating' }
56- const node = new DBClusterNode ( parentNode , clusterStatus , mockClient )
5760
61+ const node = new DBClusterNode ( parentNode , clusterStatus , mockClient )
5862 const requiresPolling = node . isStatusRequiringPolling ( )
5963
6064 assert . strictEqual ( requiresPolling , true , 'isStatusRequiringPolling should return true for creating status' )
@@ -64,18 +68,11 @@ describe('DBClusterNode', function () {
6468 const clusterStatus = { ...cluster , Status : 'creating' }
6569
6670 const trackChangesSpy = sinon . spy ( DBClusterNode . prototype , 'trackChanges' )
67-
68- // Initialize the node with a status that requires polling
6971 const node = new DBClusterNode ( parentNode , clusterStatus , mockClient )
70-
71- // Check the result of isStatusRequiringPolling
7272 const requiresPolling = node . isStatusRequiringPolling ( )
73- assert . strictEqual ( requiresPolling , true , 'isStatusRequiringPolling should return true for creating status' )
7473
75- // Assert that trackChanges was called
74+ assert . strictEqual ( requiresPolling , true , 'isStatusRequiringPolling should return true for creating status' )
7675 assert . ok ( trackChangesSpy . calledOnce , 'trackChanges should be called when polling is required' )
77-
78- // Verify the node is in the polling state
7976 assert . strictEqual ( node . isPolling , true , 'Node should be in polling state' )
8077
8178 trackChangesSpy . restore ( )
@@ -85,18 +82,11 @@ describe('DBClusterNode', function () {
8582 const clusterStatus = { ...cluster , Status : 'available' }
8683
8784 const trackChangesSpy = sinon . spy ( DBClusterNode . prototype , 'trackChanges' )
88-
89- // Initialize the node with a status that does not require polling
9085 const node = new DBClusterNode ( parentNode , clusterStatus , mockClient )
91-
92- // Check the result of isStatusRequiringPolling
9386 const requiresPolling = node . isStatusRequiringPolling ( )
94- assert . strictEqual ( requiresPolling , false , 'isStatusRequiringPolling should return false for available status' )
9587
96- // Assert that trackChanges was not called
88+ assert . strictEqual ( requiresPolling , false , 'isStatusRequiringPolling should return false for available status' )
9789 assert . ok ( trackChangesSpy . notCalled , 'trackChanges should not be called when polling is not required' )
98-
99- // Verify the node is not in the polling state
10090 assert . strictEqual ( node . isPolling , false , 'Node should not be in polling state' )
10191
10292 trackChangesSpy . restore ( )
@@ -106,36 +96,23 @@ describe('DBClusterNode', function () {
10696 const clusterStatus = { ...cluster , Status : 'available' }
10797
10898 const trackChangesSpy = sinon . spy ( DBClusterNode . prototype , 'trackChanges' )
109-
110- // Initialize the node with a status that does not require polling
11199 const node = new DBClusterNode ( parentNode , clusterStatus , mockClient )
112-
113- // Check the result of isStatusRequiringPolling
114100 const requiresPolling = node . isStatusRequiringPolling ( )
115- assert . strictEqual ( requiresPolling , false , 'isStatusRequiringPolling should return false for available status' )
116101
117- // Assert that trackChanges was not called
102+ assert . strictEqual ( requiresPolling , false , 'isStatusRequiringPolling should return false for available status' )
118103 assert . ok ( trackChangesSpy . notCalled , 'trackChanges should not be called when polling is not required' )
119-
120- // Verify the node is not in the polling state
121104 assert . strictEqual ( node . isPolling , false , 'Node should not be in polling state' )
122105
123106 trackChangesSpy . restore ( )
124107 } )
125108
126109 it ( 'has isPolling set to false and getStatus returns available when status is available' , async function ( ) {
127110 const clusterStatus = { ...cluster , Status : 'available' }
128-
129- // Mock the DocumentDB client to return the status
130111 mockClient . listClusters = sinon . stub ( ) . resolves ( [ clusterStatus ] )
131112
132- // Initialize the node with a status of 'available'
133113 const node = new DBClusterNode ( parentNode , clusterStatus , mockClient )
134114
135- // Verify the node is not in the polling state
136115 assert . strictEqual ( node . isPolling , false , 'Node should not be in polling state' )
137-
138- // Get the status from the node and verify it is 'available'
139116 assert . strictEqual ( node . status , 'available' , 'getStatus should return available for the node' )
140117 } )
141118} )
0 commit comments