@@ -44,7 +44,6 @@ describe('Subscription Variables - Edge Cases & Safety', () => {
4444 const schema = createTestSchema ( ) ;
4545 const sharedObject = { storeId : 'initial' } ;
4646
47- // First call
4847 const cache = new WeakMap ( ) ;
4948 const result1 = processSubscriptionVariables (
5049 schema . namespaces . user . models . Todo ,
@@ -53,29 +52,24 @@ describe('Subscription Variables - Edge Cases & Safety', () => {
5352 cache ,
5453 ) ;
5554
56- // Mutate the shared object
5755 sharedObject . storeId = 'mutated' ;
5856
59- // Second call - should get cached value, not mutated
6057 const result2 = processSubscriptionVariables (
6158 schema . namespaces . user . models . Todo ,
6259 TransformerMutationType . CREATE ,
6360 sharedObject ,
6461 cache ,
6562 ) ;
6663
67- // Results should be equal (same cached object)
6864 expect ( result1 ) . toEqual ( result2 ) ;
69- // But changing the original shouldn't affect results
7065 expect ( result2 ?. storeId ) . not . toBe ( 'mutated' ) ;
7166 } ) ;
7267
7368 it ( 'should handle circular references gracefully' , ( ) => {
7469 const schema = createTestSchema ( ) ;
7570 const circular : any = { storeId : 'test' } ;
76- circular . self = circular ; // Create circular reference
71+ circular . self = circular ;
7772
78- // Should handle circular reference without crashing
7973 const cache = new WeakMap ( ) ;
8074 const result = processSubscriptionVariables (
8175 schema . namespaces . user . models . Todo ,
@@ -84,7 +78,6 @@ describe('Subscription Variables - Edge Cases & Safety', () => {
8478 cache ,
8579 ) ;
8680
87- // Should return the object but not cache it (due to JSON.stringify failure)
8881 expect ( result ) . toBeDefined ( ) ;
8982 expect ( result ?. storeId ) . toBe ( 'test' ) ;
9083 } ) ;
@@ -134,7 +127,6 @@ describe('Subscription Variables - Edge Cases & Safety', () => {
134127 it ( 'should handle function that throws' , ( ) => {
135128 const schema = createTestSchema ( ) ;
136129
137- // Should not crash
138130 const cache = new WeakMap ( ) ;
139131 const mockFn = ( ) => {
140132 throw new Error ( 'Function error' ) ;
@@ -180,7 +172,6 @@ describe('Subscription Variables - Edge Cases & Safety', () => {
180172 const schema = createTestSchema ( ) ;
181173 const mockFn = jest . fn ( ( ) => ( { storeId : 'test' } ) ) ;
182174
183- // Call multiple times for same operation
184175 const cache = new WeakMap ( ) ;
185176 for ( let i = 0 ; i < 5 ; i ++ ) {
186177 processSubscriptionVariables (
@@ -191,19 +182,16 @@ describe('Subscription Variables - Edge Cases & Safety', () => {
191182 ) ;
192183 }
193184
194- // Should only be called once
195185 expect ( mockFn ) . toHaveBeenCalledTimes ( 1 ) ;
196186 expect ( mockFn ) . toHaveBeenCalledWith ( TransformerMutationType . CREATE ) ;
197187
198- // Call for different operation
199188 processSubscriptionVariables (
200189 schema . namespaces . user . models . Todo ,
201190 TransformerMutationType . UPDATE ,
202191 mockFn ,
203192 cache ,
204193 ) ;
205194
206- // Should be called again for new operation
207195 expect ( mockFn ) . toHaveBeenCalledTimes ( 2 ) ;
208196 expect ( mockFn ) . toHaveBeenCalledWith ( TransformerMutationType . UPDATE ) ;
209197 } ) ;
@@ -226,7 +214,6 @@ describe('Subscription Variables - Edge Cases & Safety', () => {
226214 } ,
227215 ) ;
228216
229- // First call
230217 let cache = new WeakMap ( ) ;
231218 processSubscriptionVariables (
232219 schema . namespaces . user . models . Todo ,
@@ -236,19 +223,16 @@ describe('Subscription Variables - Edge Cases & Safety', () => {
236223 ) ;
237224 expect ( mockFn ) . toHaveBeenCalledTimes ( 1 ) ;
238225
239- // Stop processor (clears cache) - simulate by creating new cache
240226 await processor . stop ( ) ;
241227 cache = new WeakMap ( ) ;
242228
243- // Call again after stop
244229 processSubscriptionVariables (
245230 schema . namespaces . user . models . Todo ,
246231 TransformerMutationType . CREATE ,
247232 mockFn ,
248233 cache ,
249234 ) ;
250235
251- // Should be called again since cache was cleared
252236 expect ( mockFn ) . toHaveBeenCalledTimes ( 2 ) ;
253237 } ) ;
254238 } ) ;
0 commit comments