@@ -309,4 +309,78 @@ describe('AfterburnController', () => {
309
309
const tooltip = document . querySelector ( '.afterburn-tooltip' ) ;
310
310
expect ( tooltip ) . toBeInTheDocument ( ) ;
311
311
} ) ;
312
+
313
+ it ( 'can be enabled and disabled independently' , ( ) => {
314
+ controller = new AfterburnController ( { ...defaultConfig , enabled : false } ) ;
315
+
316
+ // Controller should not respond to keyboard shortcuts initially
317
+ const keyEvent = new KeyboardEvent ( 'keydown' , {
318
+ key : 'l' ,
319
+ metaKey : true ,
320
+ shiftKey : true ,
321
+ } ) ;
322
+ document . dispatchEvent ( keyEvent ) ;
323
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( false ) ;
324
+
325
+ // Enable it
326
+ controller . enable ( ) ;
327
+
328
+ // Now keyboard shortcut should work
329
+ document . dispatchEvent ( keyEvent ) ;
330
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( true ) ;
331
+
332
+ // Disable it
333
+ controller . disable ( ) ;
334
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( false ) ;
335
+
336
+ // Keyboard shortcut should not work after disable
337
+ document . dispatchEvent ( keyEvent ) ;
338
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( false ) ;
339
+ } ) ;
340
+
341
+ it ( 'properly cleans up on destroy' , ( ) => {
342
+ controller = new AfterburnController ( defaultConfig ) ;
343
+
344
+ // Activate afterburn first
345
+ const keyEvent = new KeyboardEvent ( 'keydown' , {
346
+ key : 'l' ,
347
+ metaKey : true ,
348
+ shiftKey : true ,
349
+ } ) ;
350
+ document . dispatchEvent ( keyEvent ) ;
351
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( true ) ;
352
+
353
+ // Destroy should clean up everything
354
+ controller . destroy ( ) ;
355
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( false ) ;
356
+
357
+ // Keyboard shortcut should not work after destroy
358
+ document . dispatchEvent ( keyEvent ) ;
359
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( false ) ;
360
+ } ) ;
361
+
362
+ it ( 'responds to multiple activation methods' , ( ) => {
363
+ controller = new AfterburnController ( defaultConfig ) ;
364
+
365
+ // Initially inactive
366
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( false ) ;
367
+
368
+ // Keyboard shortcut should activate
369
+ const keyEvent = new KeyboardEvent ( 'keydown' , {
370
+ key : 'l' ,
371
+ metaKey : true ,
372
+ shiftKey : true ,
373
+ } ) ;
374
+ document . dispatchEvent ( keyEvent ) ;
375
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( true ) ;
376
+
377
+ // Keyboard shortcut should deactivate
378
+ document . dispatchEvent ( keyEvent ) ;
379
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( false ) ;
380
+
381
+ // Double-click should also activate
382
+ const doubleClickEvent = new MouseEvent ( 'click' , { detail : 2 } ) ;
383
+ document . dispatchEvent ( doubleClickEvent ) ;
384
+ expect ( document . body . classList . contains ( 'afterburn-active' ) ) . toBe ( true ) ;
385
+ } ) ;
312
386
} ) ;
0 commit comments