1+ /*!
2+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
16import * as sinon from 'sinon'
27import { LanguageClient } from 'vscode-languageclient'
38import { AuthUtil } from 'aws-core-vscode/codewhisperer'
49import { registerMessageListeners } from '../../../../../src/lsp/chat/messages'
510import { AmazonQChatViewProvider } from '../../../../../src/lsp/chat/webviewProvider'
6- import { SecondaryAuth } from '../../../../../../core/dist/src/auth/secondaryAuth'
7- import { Connection } from '../../../../../../core/dist/src/auth/connection'
11+ import { SecondaryAuth , Connection } from 'aws-core-vscode/amazonq'
812
913describe ( 'registerMessageListeners' , ( ) => {
1014 let languageClient : LanguageClient
1115 let provider : AmazonQChatViewProvider
1216 let sandbox : sinon . SinonSandbox
1317 let messageHandler : ( message : any ) => void | Promise < void >
18+ let errorStub : sinon . SinonStub
1419
1520 beforeEach ( ( ) => {
1621 sandbox = sinon . createSandbox ( )
22+ errorStub = sandbox . stub ( )
1723
1824 languageClient = {
1925 info : sandbox . stub ( ) ,
20- error : sandbox . stub ( ) ,
26+ error : errorStub ,
2127 sendNotification : sandbox . stub ( ) ,
2228 } as unknown as LanguageClient
2329
2430 provider = {
2531 webview : {
2632 onDidReceiveMessage : ( callback : ( message : any ) => void | Promise < void > ) => {
2733 messageHandler = callback
28- return { dispose : ( ) => { } }
34+ return {
35+ dispose : ( ) : void => { } ,
36+ }
2937 } ,
3038 } ,
3139 } as any
@@ -90,8 +98,8 @@ describe('registerMessageListeners', () => {
9098 } ,
9199 } )
92100
93- sinon . assert . calledOnce ( languageClient . error as sinon . SinonStub )
94- sinon . assert . calledWith ( languageClient . error as sinon . SinonStub , sinon . match ( / F a i l e d t o r e - a u t h e n t i c a t e / ) )
101+ sinon . assert . calledOnce ( errorStub )
102+ sinon . assert . calledWith ( errorStub , sinon . match ( / F a i l e d t o r e - a u t h e n t i c a t e / ) )
95103 } )
96104
97105 it ( 'should log error if full authentication fails' , async ( ) => {
@@ -104,8 +112,8 @@ describe('registerMessageListeners', () => {
104112 } ,
105113 } )
106114
107- sinon . assert . calledOnce ( languageClient . error as sinon . SinonStub )
108- sinon . assert . calledWith ( languageClient . error as sinon . SinonStub , sinon . match ( / F a i l e d t o a u t h e n t i c a t e / ) )
115+ sinon . assert . calledOnce ( errorStub )
116+ sinon . assert . calledWith ( errorStub , sinon . match ( / F a i l e d t o a u t h e n t i c a t e / ) )
109117 } )
110118 } )
111119} )
0 commit comments