@@ -23,6 +23,7 @@ describe('ec2ParentNode', function () {
23
23
let clock : FakeTimers . InstalledClock
24
24
let refreshStub : sinon . SinonStub < [ ] , Promise < void > >
25
25
let clearTimerStub : sinon . SinonStub < [ ] , void >
26
+ let statusUpdateFromClient : string
26
27
27
28
const testRegion = 'testRegion'
28
29
const testPartition = 'testPartition'
@@ -38,13 +39,14 @@ describe('ec2ParentNode', function () {
38
39
} ) )
39
40
)
40
41
)
42
+ client . getInstanceStatus . callsFake ( async ( ) => statusUpdateFromClient )
41
43
42
44
return client
43
45
}
44
46
45
47
before ( function ( ) {
46
48
clock = installFakeClock ( )
47
- refreshStub = sinon . stub ( Ec2ParentNode . prototype , 'refreshNode' )
49
+ refreshStub = sinon . stub ( Ec2InstanceNode . prototype , 'refreshNode' )
48
50
clearTimerStub = sinon . stub ( Ec2ParentNode . prototype , 'clearPollTimer' )
49
51
} )
50
52
@@ -126,15 +128,24 @@ describe('ec2ParentNode', function () {
126
128
assert . strictEqual ( testNode . pollingNodes . size , 1 )
127
129
} )
128
130
129
- it ( 'refreshes explorer when timer goes off' , async function ( ) {
131
+ it ( 'does not refresh explorer when timer goes off if status unchanged' , async function ( ) {
132
+ statusUpdateFromClient = 'pending'
130
133
instances = [
131
134
{ name : 'firstOne' , InstanceId : '0' , status : 'pending' } ,
132
135
{ name : 'secondOne' , InstanceId : '1' , status : 'stopped' } ,
133
136
{ name : 'thirdOne' , InstanceId : '2' , status : 'running' } ,
134
137
]
135
138
await testNode . updateChildren ( )
136
139
await clock . tickAsync ( 6000 )
137
- sinon . assert . calledOn ( refreshStub , testNode )
140
+ sinon . assert . notCalled ( refreshStub )
141
+ } )
142
+
143
+ it ( 'does refresh explorer when timer goes and status changed' , async function ( ) {
144
+ sinon . assert . notCalled ( refreshStub )
145
+ statusUpdateFromClient = 'running'
146
+ testNode . pollingNodes . add ( '0' )
147
+ await clock . tickAsync ( 6000 )
148
+ sinon . assert . called ( refreshStub )
138
149
} )
139
150
140
151
it ( 'stops timer once polling nodes are empty' , async function ( ) {
0 commit comments