66import assert from 'assert'
77import * as FakeTimers from '@sinonjs/fake-timers'
88import * as sinon from 'sinon'
9- import { AppRunner } from 'aws-sdk'
109import { AppRunnerNode } from '../../../../awsService/apprunner/explorer/apprunnerNode'
1110import { AppRunnerServiceNode } from '../../../../awsService/apprunner/explorer/apprunnerServiceNode'
12- import { AppRunnerClient } from '../../../../shared/clients/apprunner'
11+ import { AppRunnerClient , AppRunnerServiceSummary } from '../../../../shared/clients/apprunner'
1312import { PlaceholderNode } from '../../../../shared/treeview/nodes/placeholderNode'
1413import { AWSTreeNodeBase } from '../../../../shared/treeview/nodes/awsTreeNodeBase'
1514import { installFakeClock } from '../../../testUtil'
15+ import { intoCollection } from '../../../../shared/utilities/collectionUtils'
1616
1717describe ( 'AppRunnerNode' , function ( ) {
1818 let mockApprunnerClient : AppRunnerClient
1919 let node : AppRunnerNode
2020 let clock : FakeTimers . InstalledClock
2121 let refreshStub : sinon . SinonStub < [ ] , void >
2222
23- const exampleSummaries : AppRunner . ServiceSummaryList = [
23+ const exampleSummaries : AppRunnerServiceSummary [ ] = [
2424 {
2525 ServiceName : 'test1' ,
2626 Status : 'RUNNING' ,
2727 ServiceArn : 'test-arn1' ,
28+ ServiceId : 'Amazon' ,
2829 } ,
2930 ]
3031
@@ -35,7 +36,7 @@ describe('AppRunnerNode', function () {
3536
3637 beforeEach ( function ( ) {
3738 mockApprunnerClient = {
38- listServices : sinon . stub ( ) . resolves ( { ServiceSummaryList : exampleSummaries } ) ,
39+ paginateServices : sinon . stub ( ) . returns ( intoCollection ( [ exampleSummaries ] ) ) ,
3940 listOperations : sinon . stub ( ) . resolves ( { OperationSummaryList : [ ] } ) ,
4041 } as any as AppRunnerClient
4142 node = new AppRunnerNode ( '' , mockApprunnerClient )
@@ -56,17 +57,17 @@ describe('AppRunnerNode', function () {
5657 const childNode = ( await node . getChildren ( ) ) [ 0 ] as AppRunnerServiceNode
5758
5859 const updatedSummary = { ...exampleSummaries [ 0 ] , Status : 'PAUSED' }
59- const serviceStub = sinon . stub ( ) . resolves ( { ServiceSummaryList : [ updatedSummary ] } )
60- mockApprunnerClient . listServices = serviceStub
60+ const serviceStub = sinon . stub ( ) . returns ( intoCollection ( [ [ updatedSummary ] ] ) )
61+ mockApprunnerClient . paginateServices = serviceStub
6162
6263 await node . getChildren ( )
6364 assert . strictEqual ( childNode . info . Status , 'PAUSED' )
6465 } )
6566
6667 it ( 'deletes AppRunnerServiceNodes' , async function ( ) {
6768 await node . getChildren ( )
68- const serviceStub = sinon . stub ( ) . resolves ( { ServiceSummaryList : [ ] } )
69- mockApprunnerClient . listServices = serviceStub
69+ const serviceStub = sinon . stub ( ) . returns ( intoCollection ( [ [ ] ] ) )
70+ mockApprunnerClient . paginateServices = serviceStub
7071
7172 assert . ok ( ( await node . getChildren ( ) ) [ 0 ] instanceof PlaceholderNode )
7273 } )
@@ -77,10 +78,10 @@ describe('AppRunnerNode', function () {
7778 const serviceStub = sinon
7879 . stub ( )
7980 . onFirstCall ( )
80- . resolves ( { ServiceSummaryList : [ transientService ] } )
81+ . returns ( intoCollection ( [ [ transientService ] ] ) )
8182 . onSecondCall ( )
82- . resolves ( { ServiceSummaryList : [ pausedService ] } )
83- mockApprunnerClient . listServices = serviceStub
83+ . returns ( intoCollection ( [ [ pausedService ] ] ) )
84+ mockApprunnerClient . paginateServices = serviceStub
8485 const opStub = sinon . stub ( ) . resolves ( {
8586 OperationSummaryList : [ { Id : 'test-id' , Type : 'PAUSE_SERVICE' } ] ,
8687 } )
0 commit comments