Skip to content

Commit dd82ff9

Browse files
committed
refactor tests to avoid polling before tests start
1 parent 177aa07 commit dd82ff9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/test/ec2/explorer/ec2ParentNode.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ describe('ec2ParentNode', function () {
5050

5151
beforeEach(function () {
5252
instances = [
53-
{ name: 'firstOne', InstanceId: '0', status: 'pending' },
53+
{ name: 'firstOne', InstanceId: '0', status: 'running' },
5454
{ name: 'secondOne', InstanceId: '1', status: 'stopped' },
5555
]
5656

5757
testNode = new Ec2ParentNode(testRegion, testPartition, createClient())
58+
refreshStub.resetHistory()
5859
})
5960

6061
it('returns placeholder node if no children are present', async function () {
@@ -116,18 +117,34 @@ describe('ec2ParentNode', function () {
116117
})
117118

118119
it('adds pending nodes to the polling nodes set', async function () {
120+
instances = [
121+
{ name: 'firstOne', InstanceId: '0', status: 'pending' },
122+
{ name: 'secondOne', InstanceId: '1', status: 'stopped' },
123+
{ name: 'thirdOne', InstanceId: '2', status: 'running' },
124+
]
119125
await testNode.updateChildren()
120126
assert.strictEqual(testNode.pollingNodes.size, 1)
121127
})
122128

123129
it('refreshes explorer when timer goes off', async function () {
130+
instances = [
131+
{ name: 'firstOne', InstanceId: '0', status: 'pending' },
132+
{ name: 'secondOne', InstanceId: '1', status: 'stopped' },
133+
{ name: 'thirdOne', InstanceId: '2', status: 'running' },
134+
]
124135
await testNode.updateChildren()
125136
await clock.tickAsync(6000)
126137
sinon.assert.calledOn(refreshStub, testNode)
127138
})
128139

129140
it('stops timer once polling nodes are empty', async function () {
141+
instances = [
142+
{ name: 'firstOne', InstanceId: '0', status: 'pending' },
143+
{ name: 'secondOne', InstanceId: '1', status: 'stopped' },
144+
{ name: 'thirdOne', InstanceId: '2', status: 'running' },
145+
]
130146
await testNode.updateChildren()
147+
131148
assert.strictEqual(testNode.isPolling(), true)
132149
testNode.pollingNodes.delete('0')
133150
await clock.tickAsync(6000)

0 commit comments

Comments
 (0)