@@ -16,7 +16,6 @@ import {
16
16
} from '../../utilities/explorerNodeAssertions'
17
17
import { Ec2InstanceNode } from '../../../ec2/explorer/ec2InstanceNode'
18
18
import { installFakeClock } from '../../testUtil'
19
- import { mock , when } from 'ts-mockito'
20
19
21
20
describe ( 'ec2ParentNode' , function ( ) {
22
21
let testNode : Ec2ParentNode
@@ -33,6 +32,7 @@ describe('ec2ParentNode', function () {
33
32
intoCollection (
34
33
instances . map ( instance => ( {
35
34
InstanceId : instance . InstanceId ,
35
+ status : instance . status ,
36
36
Tags : [ { Key : 'Name' , Value : instance . name } ] ,
37
37
} ) )
38
38
)
@@ -113,18 +113,32 @@ describe('ec2ParentNode', function () {
113
113
assert . strictEqual ( testNode . isPolling ( ) , false )
114
114
} )
115
115
116
- it ( 'updates the nodes when the timer is up' , async function ( ) {
117
- const mockChildNode : Ec2InstanceNode = mock ( )
118
- testNode . startPolling ( mockChildNode )
119
- await clock . tickAsync ( 4000 )
120
- sinon . assert . calledOn ( refreshStub , testNode )
116
+ it ( 'adds pending nodes to the polling nodes set' , async function ( ) {
117
+ await testNode . updateChildren ( )
118
+ assert . strictEqual ( testNode . pollingNodes . size , 1 )
121
119
} )
122
120
123
- it ( 'deletes node from polling set when state changes' , async function ( ) {
124
- const mockChildNode : Ec2InstanceNode = mock ( )
125
- when ( mockChildNode . getStatus ( ) ) . thenReturn ( 'running' )
126
- testNode . startPolling ( mockChildNode )
127
- await clock . tickAsync ( 4000 )
128
- assert . strictEqual ( testNode . isPolling ( ) , false )
121
+ it ( 'refreshes explorer when timer goes off' , async function ( ) {
122
+ await testNode . updateChildren ( )
123
+ await clock . tickAsync ( 6000 )
124
+ sinon . assert . calledOn ( refreshStub , testNode )
129
125
} )
126
+
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
+ // })
130
144
} )
0 commit comments