@@ -17,16 +17,13 @@ import { EC2 } from 'aws-sdk'
1717import { AsyncCollection } from '../../../../shared/utilities/asyncCollection'
1818import * as FakeTimers from '@sinonjs/fake-timers'
1919import { installFakeClock } from '../../../testUtil'
20- import { PollingSet } from '../../../../shared/utilities/pollingSet'
2120
2221describe ( 'ec2ParentNode' , function ( ) {
2322 let testNode : Ec2ParentNode
24- let defaultInstances : SafeEc2Instance [ ]
2523 let client : Ec2Client
2624 let getInstanceStub : sinon . SinonStub < [ filters ?: EC2 . Filter [ ] | undefined ] , Promise < AsyncCollection < EC2 . Instance > > >
2725 let clock : FakeTimers . InstalledClock
2826 let refreshStub : sinon . SinonStub < [ ] , Promise < void > >
29- let clearTimerStub : sinon . SinonStub < [ ] , void >
3027
3128 const testRegion = 'testRegion'
3229 const testPartition = 'testPartition'
@@ -45,32 +42,12 @@ describe('ec2ParentNode', function () {
4542 client = new Ec2Client ( testRegion )
4643 clock = installFakeClock ( )
4744 refreshStub = sinon . stub ( Ec2InstanceNode . prototype , 'refreshNode' )
48- clearTimerStub = sinon . stub ( PollingSet . prototype , 'clearTimer' )
49- defaultInstances = [
50- { Name : 'firstOne' , InstanceId : '0' , LastSeenStatus : 'running' } ,
51- { Name : 'secondOne' , InstanceId : '1' , LastSeenStatus : 'running' } ,
52- ]
5345 } )
5446
5547 beforeEach ( function ( ) {
5648 getInstanceStub = sinon . stub ( Ec2Client . prototype , 'getInstances' )
57- defaultInstances = [
58- { Name : 'firstOne' , InstanceId : '0' , LastSeenStatus : 'running' } ,
59- { Name : 'secondOne' , InstanceId : '1' , LastSeenStatus : 'stopped' } ,
60- ]
61-
62- getInstanceStub . callsFake ( async ( ) =>
63- intoCollection (
64- defaultInstances . map ( ( instance ) => ( {
65- InstanceId : instance . InstanceId ,
66- Tags : [ { Key : 'Name' , Value : instance . Name } ] ,
67- } ) )
68- )
69- )
70-
7149 testNode = new Ec2ParentNode ( testRegion , testPartition , client )
7250 refreshStub . resetHistory ( )
73- clearTimerStub . resetHistory ( )
7451 } )
7552
7653 afterEach ( function ( ) {
@@ -91,10 +68,14 @@ describe('ec2ParentNode', function () {
9168 } )
9269
9370 it ( 'has instance child nodes' , async function ( ) {
94- getInstanceStub . resolves ( mapToInstanceCollection ( defaultInstances ) )
71+ const instances = [
72+ { Name : 'firstOne' , InstanceId : '0' , LastSeenStatus : 'running' } ,
73+ { Name : 'secondOne' , InstanceId : '1' , LastSeenStatus : 'stopped' } ,
74+ ]
75+ getInstanceStub . resolves ( mapToInstanceCollection ( instances ) )
9576 const childNodes = await testNode . getChildren ( )
9677
97- assert . strictEqual ( childNodes . length , defaultInstances . length , 'Unexpected child count' )
78+ assert . strictEqual ( childNodes . length , instances . length , 'Unexpected child count' )
9879
9980 childNodes . forEach ( ( node ) =>
10081 assert . ok ( node instanceof Ec2InstanceNode , 'Expected child node to be Ec2InstanceNode' )
0 commit comments