@@ -82,10 +82,6 @@ describe('model', function () {
8282
8383 beforeEach ( function ( ) {
8484 sandbox = sinon . createSandbox ( )
85- // Reset the singleton instance before each test
86- // @ts -ignore - accessing private static for testing
87- CodeIssueGroupingStrategyState [ '#instance' ] = undefined
88- state = CodeIssueGroupingStrategyState . instance
8985 } )
9086
9187 afterEach ( function ( ) {
@@ -102,16 +98,14 @@ describe('model', function () {
10298
10399 describe ( 'getState' , function ( ) {
104100 it ( 'should return fallback when no state is stored' , function ( ) {
105- const tryGetStub = sandbox . stub ( globals . globalState , 'tryGet' ) . returns ( undefined )
106101 const result = state . getState ( )
107102
108- sinon . assert . calledWith ( tryGetStub , 'aws.amazonq.codescan.groupingStrategy' , String )
109103 assert . equal ( result , CodeIssueGroupingStrategy . Severity )
110104 } )
111105
112106 it ( 'should return stored state when valid' , function ( ) {
113- const validStrategy = CodeIssueGroupingStrategy . Severity
114- sandbox . stub ( globals . globalState , 'tryGet' ) . returns ( validStrategy )
107+ const validStrategy = CodeIssueGroupingStrategy . FileLocation
108+ state . setState ( validStrategy )
115109
116110 const result = state . getState ( )
117111
@@ -120,7 +114,7 @@ describe('model', function () {
120114
121115 it ( 'should return fallback when stored state is invalid' , function ( ) {
122116 const invalidStrategy = 'invalid'
123- sandbox . stub ( globals . globalState , 'tryGet' ) . returns ( invalidStrategy )
117+ state . setState ( invalidStrategy )
124118
125119 const result = state . getState ( )
126120
@@ -131,33 +125,25 @@ describe('model', function () {
131125 describe ( 'setState' , function ( ) {
132126 it ( 'should update state and fire change event for valid strategy' , async function ( ) {
133127 const validStrategy = CodeIssueGroupingStrategy . FileLocation
134- const updateStub = sandbox . stub ( globals . globalState , 'update' ) . resolves ( )
135128
136129 // Create a spy to watch for event emissions
137130 const eventSpy = sandbox . spy ( )
138131 state . onDidChangeState ( eventSpy )
139132
140133 await state . setState ( validStrategy )
141134
142- sinon . assert . calledWith ( updateStub , 'aws.amazonq.codescan.groupingStrategy' , validStrategy )
143135 sinon . assert . calledWith ( eventSpy , validStrategy )
144136 } )
145137
146138 it ( 'should use fallback and fire change event for invalid strategy' , async function ( ) {
147139 const invalidStrategy = 'invalid'
148- const updateStub = sandbox . stub ( globals . globalState , 'update' ) . resolves ( )
149140
150141 // Create a spy to watch for event emissions
151142 const eventSpy = sandbox . spy ( )
152143 state . onDidChangeState ( eventSpy )
153144
154145 await state . setState ( invalidStrategy )
155146
156- sinon . assert . calledWith (
157- updateStub ,
158- 'aws.amazonq.codescan.groupingStrategy' ,
159- CodeIssueGroupingStrategy . Severity
160- )
161147 sinon . assert . calledWith ( eventSpy , CodeIssueGroupingStrategy . Severity )
162148 } )
163149 } )
0 commit comments