Skip to content

Commit 63d5450

Browse files
committed
be more careful with stubbing
1 parent ab1056d commit 63d5450

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/core/src/test/awsService/ec2/explorer/ec2ParentNode.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('ec2ParentNode', function () {
2424
let getInstanceStub: sinon.SinonStub<[filters?: EC2.Filter[] | undefined], Promise<AsyncCollection<EC2.Instance>>>
2525
let clock: FakeTimers.InstalledClock
2626
let refreshStub: sinon.SinonStub<[], Promise<void>>
27+
let statusUpdateStub: sinon.SinonStub<[status: string], Promise<string>>
2728
const testRegion = 'testRegion'
2829
const testPartition = 'testPartition'
2930

@@ -41,7 +42,7 @@ describe('ec2ParentNode', function () {
4142
client = new Ec2Client(testRegion)
4243
clock = installFakeClock()
4344
refreshStub = sinon.stub(Ec2InstanceNode.prototype, 'refreshNode')
44-
sinon.stub(Ec2InstanceNode.prototype, 'updateStatus')
45+
statusUpdateStub = sinon.stub(Ec2Client.prototype, 'getInstanceStatus')
4546
})
4647

4748
beforeEach(function () {
@@ -140,7 +141,7 @@ describe('ec2ParentNode', function () {
140141
})
141142

142143
it('does not refresh explorer when timer goes off if status unchanged', async function () {
143-
const statusUpdateStub = sinon.stub(Ec2Client.prototype, 'getInstanceStatus').resolves('pending')
144+
statusUpdateStub = statusUpdateStub.resolves('pending')
144145
const instances = [
145146
{ Name: 'firstOne', InstanceId: '0', LastSeenStatus: 'pending' },
146147
{ Name: 'secondOne', InstanceId: '1', LastSeenStatus: 'stopped' },
@@ -152,12 +153,11 @@ describe('ec2ParentNode', function () {
152153
await testNode.updateChildren()
153154
await clock.tickAsync(6000)
154155
sinon.assert.notCalled(refreshStub)
155-
statusUpdateStub.restore()
156156
getInstanceStub.restore()
157157
})
158158

159159
it('does refresh explorer when timer goes and status changed', async function () {
160-
const statusUpdateStub = sinon.stub(Ec2Client.prototype, 'getInstanceStatus').resolves('running')
160+
statusUpdateStub = statusUpdateStub.resolves('running')
161161
const instances = [{ Name: 'firstOne', InstanceId: '0', LastSeenStatus: 'pending' }]
162162

163163
getInstanceStub.resolves(mapToInstanceCollection(instances))
@@ -166,7 +166,6 @@ describe('ec2ParentNode', function () {
166166
sinon.assert.notCalled(refreshStub)
167167
await clock.tickAsync(6000)
168168
sinon.assert.called(refreshStub)
169-
statusUpdateStub.restore()
170169
})
171170

172171
it('returns the node when in the map', async function () {

0 commit comments

Comments
 (0)