@@ -22,6 +22,7 @@ describe('ec2ParentNode', function () {
22
22
let instances : Ec2Instance [ ]
23
23
let clock : FakeTimers . InstalledClock
24
24
let refreshStub : sinon . SinonStub < [ ] , Promise < void > >
25
+ let clearTimerStub : sinon . SinonStub < [ ] , void >
25
26
26
27
const testRegion = 'testRegion'
27
28
const testPartition = 'testPartition'
@@ -44,6 +45,7 @@ describe('ec2ParentNode', function () {
44
45
before ( function ( ) {
45
46
clock = installFakeClock ( )
46
47
refreshStub = sinon . stub ( Ec2ParentNode . prototype , 'refreshNode' )
48
+ clearTimerStub = sinon . stub ( Ec2ParentNode . prototype , 'clearPollTimer' )
47
49
} )
48
50
49
51
beforeEach ( function ( ) {
@@ -124,21 +126,12 @@ describe('ec2ParentNode', function () {
124
126
sinon . assert . calledOn ( refreshStub , testNode )
125
127
} )
126
128
127
- // it('deletes node from polling set when state changes', async function () {
128
- // const mockChildNode: Ec2InstanceNode = mock()
129
- // when(mockChildNode.getStatus()).thenReturn('running')
130
- // testNode.startPolling(mockChildNode)
131
- // await clock.tickAsync(4000)
132
- // assert.strictEqual(testNode.isPolling(), false)
133
- // })
134
-
135
- // it('stops polling once node status has been updated', async function () {
136
- // const mockChildNode: Ec2InstanceNode = mock()
137
- // when(mockChildNode.getStatus()).thenReturn('running')
138
- // testNode.startPolling(mockChildNode)
139
- // await clock.tickAsync(4000)
140
- // sinon.assert.calledOn(refreshStub, testNode)
141
- // await clock.tickAsync(4000)
142
- // sinon.assert.calledOnce(refreshStub)
143
- // })
129
+ it ( 'stops timer once polling nodes are empty' , async function ( ) {
130
+ await testNode . updateChildren ( )
131
+ assert . strictEqual ( testNode . isPolling ( ) , true )
132
+ testNode . pollingNodes . delete ( '0' )
133
+ await clock . tickAsync ( 6000 )
134
+ assert . strictEqual ( testNode . isPolling ( ) , false )
135
+ sinon . assert . calledOn ( clearTimerStub , testNode )
136
+ } )
144
137
} )
0 commit comments