@@ -11,6 +11,7 @@ import {
1111} from "../../../src/telemetry" ;
1212import { UserCancellationException } from "../../../src/commandRunner" ;
1313import { ENABLE_TELEMETRY } from "../../../src/config" ;
14+ import * as Config from "../../../src/config" ;
1415import { createMockExtensionContext } from "./index" ;
1516
1617// setting preferences can trigger lots of background activity
@@ -388,6 +389,37 @@ describe("telemetry reporting", () => {
388389 expect ( showInformationMessageSpy ) . toBeCalledTimes ( 1 ) ;
389390 } ) ;
390391
392+ describe ( "when new telementry is not enabled" , ( ) => {
393+ it ( "should not send a telementry event" , async ( ) => {
394+ await telemetryListener . initialize ( ) ;
395+
396+ telemetryListener . sendUIInteraction ( "test" ) ;
397+
398+ expect ( sendTelemetryEventSpy ) . not . toBeCalled ( ) ;
399+ } ) ;
400+ } ) ;
401+
402+ describe ( "when new telementry is enabled" , ( ) => {
403+ beforeEach ( async ( ) => {
404+ jest . spyOn ( Config , "newTelemetryEnabled" ) . mockReturnValue ( true ) ;
405+ } ) ;
406+
407+ it ( "should not send a telementry event" , async ( ) => {
408+ await telemetryListener . initialize ( ) ;
409+
410+ telemetryListener . sendUIInteraction ( "test" ) ;
411+
412+ expect ( sendTelemetryEventSpy ) . toHaveBeenCalledWith (
413+ "ui-interaction" ,
414+ {
415+ name : "test" ,
416+ isCanary,
417+ } ,
418+ { } ,
419+ ) ;
420+ } ) ;
421+ } ) ;
422+
391423 async function enableTelemetry ( section : string , value : boolean | undefined ) {
392424 await workspace
393425 . getConfiguration ( section )
0 commit comments