@@ -8,7 +8,7 @@ import * as vscode from 'vscode'
88import * as sinon from 'sinon'
99import {
1010 ReferenceInlineProvider ,
11- CodeWhispererSessionState ,
11+ session ,
1212 AuthUtil ,
1313 DefaultCodeWhispererClient ,
1414 RecommendationsList ,
@@ -55,7 +55,6 @@ describe('recommendationHandler', function () {
5555 } )
5656
5757 it ( 'should assign correct recommendations given input' , async function ( ) {
58- const session = CodeWhispererSessionState . instance . getSession ( )
5958 assert . strictEqual ( CodeWhispererCodeCoverageTracker . instances . size , 0 )
6059 assert . strictEqual (
6160 CodeWhispererCodeCoverageTracker . getTracker ( mockEditor . document . languageId ) ?. serviceInvocationCount ,
@@ -75,7 +74,7 @@ describe('recommendationHandler', function () {
7574 }
7675 const handler = new RecommendationHandler ( )
7776 sinon . stub ( handler , 'getServerResponse' ) . resolves ( mockServerResult )
78- await handler . getRecommendations ( mockClient , mockEditor , 'AutoTrigger' , config , session , 'Enter' , false )
77+ await handler . getRecommendations ( mockClient , mockEditor , 'AutoTrigger' , config , 'Enter' , false )
7978 const actual = session . recommendations
8079 const expected : RecommendationsList = [ { content : "print('Hello World!')" } , { content : '' } ]
8180 assert . deepStrictEqual ( actual , expected )
@@ -86,7 +85,6 @@ describe('recommendationHandler', function () {
8685 } )
8786
8887 it ( 'should assign request id correctly' , async function ( ) {
89- const session = CodeWhispererSessionState . instance . getSession ( )
9088 const mockServerResult = {
9189 recommendations : [ { content : "print('Hello World!')" } , { content : '' } ] ,
9290 $response : {
@@ -101,7 +99,7 @@ describe('recommendationHandler', function () {
10199 const handler = new RecommendationHandler ( )
102100 sinon . stub ( handler , 'getServerResponse' ) . resolves ( mockServerResult )
103101 sinon . stub ( handler , 'isCancellationRequested' ) . returns ( false )
104- await handler . getRecommendations ( mockClient , mockEditor , 'AutoTrigger' , config , session , 'Enter' , false )
102+ await handler . getRecommendations ( mockClient , mockEditor , 'AutoTrigger' , config , 'Enter' , false )
105103 assert . strictEqual ( handler . requestId , 'test_request' )
106104 assert . strictEqual ( session . sessionId , 'test_request' )
107105 assert . strictEqual ( session . triggerType , 'AutoTrigger' )
@@ -130,10 +128,9 @@ describe('recommendationHandler', function () {
130128 strategy : 'empty' ,
131129 } )
132130 sinon . stub ( performance , 'now' ) . returns ( 0.0 )
133- const session = CodeWhispererSessionState . instance . getSession ( )
134131 session . startPos = new vscode . Position ( 1 , 0 )
135132 session . startCursorOffset = 2
136- await handler . getRecommendations ( mockClient , mockEditor , 'AutoTrigger' , config , session , 'Enter' )
133+ await handler . getRecommendations ( mockClient , mockEditor , 'AutoTrigger' , config , 'Enter' )
137134 const assertTelemetry = assertTelemetryCurried ( 'codewhisperer_serviceInvocation' )
138135 assertTelemetry ( {
139136 codewhispererRequestId : 'test_request' ,
@@ -170,11 +167,10 @@ describe('recommendationHandler', function () {
170167 const handler = new RecommendationHandler ( )
171168 sinon . stub ( handler , 'getServerResponse' ) . resolves ( mockServerResult )
172169 sinon . stub ( performance , 'now' ) . returns ( 0.0 )
173- const session = CodeWhispererSessionState . instance . getSession ( )
174170 session . startPos = new vscode . Position ( 1 , 0 )
175171 session . requestIdList = [ 'test_request_empty' ]
176172 session . startCursorOffset = 2
177- await handler . getRecommendations ( mockClient , mockEditor , 'AutoTrigger' , config , session , 'Enter' )
173+ await handler . getRecommendations ( mockClient , mockEditor , 'AutoTrigger' , config , 'Enter' )
178174 const assertTelemetry = assertTelemetryCurried ( 'codewhisperer_userDecision' )
179175 assertTelemetry ( {
180176 codewhispererRequestId : 'test_request_empty' ,
@@ -196,7 +192,6 @@ describe('recommendationHandler', function () {
196192 sinon . restore ( )
197193 } )
198194 it ( 'should return true if any response is not empty' , function ( ) {
199- const session = CodeWhispererSessionState . instance . getSession ( )
200195 const handler = new RecommendationHandler ( )
201196 session . recommendations = [
202197 {
@@ -209,14 +204,12 @@ describe('recommendationHandler', function () {
209204 } )
210205
211206 it ( 'should return false if response is empty' , function ( ) {
212- const session = CodeWhispererSessionState . instance . getSession ( )
213207 const handler = new RecommendationHandler ( )
214208 session . recommendations = [ ]
215209 assert . ok ( ! handler . isValidResponse ( ) )
216210 } )
217211
218212 it ( 'should return false if all response has no string length' , function ( ) {
219- const session = CodeWhispererSessionState . instance . getSession ( )
220213 const handler = new RecommendationHandler ( )
221214 session . recommendations = [ { content : '' } , { content : '' } ]
222215 assert . ok ( ! handler . isValidResponse ( ) )
@@ -229,7 +222,6 @@ describe('recommendationHandler', function () {
229222 } )
230223
231224 it ( 'should set the completion type to block given a multi-line suggestion' , function ( ) {
232- const session = CodeWhispererSessionState . instance . getSession ( )
233225 session . setCompletionType ( 0 , { content : 'test\n\n \t\r\nanother test' } )
234226 assert . strictEqual ( session . getCompletionType ( 0 ) , 'Block' )
235227
@@ -241,7 +233,6 @@ describe('recommendationHandler', function () {
241233 } )
242234
243235 it ( 'should set the completion type to line given a single-line suggestion' , function ( ) {
244- const session = CodeWhispererSessionState . instance . getSession ( )
245236 session . setCompletionType ( 0 , { content : 'test' } )
246237 assert . strictEqual ( session . getCompletionType ( 0 ) , 'Line' )
247238
@@ -250,7 +241,6 @@ describe('recommendationHandler', function () {
250241 } )
251242
252243 it ( 'should set the completion type to line given a multi-line completion but only one-lien of non-blank sequence' , function ( ) {
253- const session = CodeWhispererSessionState . instance . getSession ( )
254244 session . setCompletionType ( 0 , { content : 'test\n\t' } )
255245 assert . strictEqual ( session . getCompletionType ( 0 ) , 'Line' )
256246
@@ -267,7 +257,6 @@ describe('recommendationHandler', function () {
267257
268258 describe ( 'on event change' , async function ( ) {
269259 beforeEach ( function ( ) {
270- const session = CodeWhispererSessionState . instance . getSession ( )
271260 const fakeReferences = [
272261 {
273262 message : '' ,
@@ -285,14 +274,12 @@ describe('recommendationHandler', function () {
285274 } )
286275
287276 it ( 'should remove inline reference onEditorChange' , async function ( ) {
288- const session = CodeWhispererSessionState . instance . getSession ( )
289277 session . sessionId = 'aSessionId'
290278 RecommendationHandler . instance . requestId = 'aRequestId'
291279 await RecommendationHandler . instance . onEditorChange ( )
292280 assert . strictEqual ( ReferenceInlineProvider . instance . refs . length , 0 )
293281 } )
294282 it ( 'should remove inline reference onFocusChange' , async function ( ) {
295- const session = CodeWhispererSessionState . instance . getSession ( )
296283 session . sessionId = 'aSessionId'
297284 RecommendationHandler . instance . requestId = 'aRequestId'
298285 await RecommendationHandler . instance . onFocusChange ( )
0 commit comments