@@ -526,11 +526,13 @@ describe('LdkClient', () => {
526526
527527 describe ( 'Client User-Agent' , ( ) => {
528528 let expectedUserAgentPairs : UserAgent
529- before ( ( ) => {
529+ let userAgentSandbox : sinon . SinonSandbox
530+ beforeEach ( ( ) => {
531+ userAgentSandbox = sinon . createSandbox ( )
530532 // Stub getUserAgentPairs at the telemetryUtil level to return known pairs
531- const getUserAgentPairsStub = sandbox . stub ( telemetryUtil , 'getUserAgentPairs' )
533+ const getUserAgentPairsStub = userAgentSandbox . stub ( telemetryUtil , 'getUserAgentPairs' )
532534 const generalUserAgents : UserAgent = [
533- [ 'AWS-Toolkit-For-VSCode' , 'testVersion ' ] ,
535+ [ 'AWS-Toolkit-For-VSCode' , 'testVersionForUA ' ] ,
534536 [ 'Visual-Studio-Code' , '1.0.0' ] ,
535537 [ 'ClientId' , 'test-client-id' ] ,
536538 ]
@@ -539,6 +541,10 @@ describe('LdkClient', () => {
539541 expectedUserAgentPairs = lambdaDebugUserAgent . concat ( generalUserAgents )
540542 } )
541543
544+ afterEach ( ( ) => {
545+ userAgentSandbox . restore ( )
546+ } )
547+
542548 it ( 'should create Lambda client with correct user-agent' , async ( ) => {
543549 // Restore the existing stub and create a new one to track calls
544550 const existingStub = ( utils . getLambdaClientWithAgent as any ) . restore
@@ -550,7 +556,7 @@ describe('LdkClient', () => {
550556
551557 // Stub the Lambda sdkClientBuilderV3 to capture the client options
552558 let capturedClientOptions : any
553- const createAwsServiceStubLambda = sandbox . stub ( globals . sdkClientBuilderV3 , 'createAwsService' )
559+ const createAwsServiceStubLambda = userAgentSandbox . stub ( globals . sdkClientBuilderV3 , 'createAwsService' )
554560 createAwsServiceStubLambda . callsFake ( ( options : any ) => {
555561 capturedClientOptions = options
556562 // Return a mock Lambda client that has the required methods
@@ -590,7 +596,7 @@ describe('LdkClient', () => {
590596 }
591597 // Stub the sdkClientBuilderV3 to capture the client options
592598 let capturedClientOptions : any
593- const createAwsServiceStubIoT = sandbox . stub ( globals . sdkClientBuilderV3 , 'createAwsService' )
599+ const createAwsServiceStubIoT = userAgentSandbox . stub ( globals . sdkClientBuilderV3 , 'createAwsService' )
594600 createAwsServiceStubIoT . callsFake ( ( options : any ) => {
595601 capturedClientOptions = options
596602 return mockIoTSTClient as any
0 commit comments