@@ -11,6 +11,7 @@ import { expect } from 'chai';
11
11
import * as sinon from 'sinon' ;
12
12
import { AppInsights } from '../../src/appInsights' ;
13
13
import { TelemetryReporter } from '../../src/telemetryReporter' ;
14
+ import * as enabledStubs from '../../src/enabledCheck' ;
14
15
15
16
describe ( 'TelemetryReporter' , ( ) => {
16
17
const key = 'foo-bar-123' ;
@@ -75,7 +76,7 @@ describe('TelemetryReporter', () => {
75
76
} ) ;
76
77
77
78
it ( 'should not send a telemetry event when disabled' , async ( ) => {
78
- sandbox . stub ( ConfigAggregator . prototype , 'getPropertyValue ' ) . returns ( 'true' ) ;
79
+ sandbox . stub ( enabledStubs , 'isEnabled ' ) . resolves ( false ) ;
79
80
const options = { project, key } ;
80
81
const reporter = await TelemetryReporter . create ( options ) ;
81
82
const sendStub = sandbox . stub ( reporter . getTelemetryClient ( ) , 'trackEvent' ) . callsFake ( ( ) => { } ) ;
@@ -85,7 +86,7 @@ describe('TelemetryReporter', () => {
85
86
} ) ;
86
87
87
88
it ( 'should not send a telemetry exception when disabled' , async ( ) => {
88
- sandbox . stub ( ConfigAggregator . prototype , 'getPropertyValue ' ) . returns ( 'true' ) ;
89
+ sandbox . stub ( enabledStubs , 'isEnabled ' ) . resolves ( false ) ;
89
90
const options = { project, key } ;
90
91
const reporter = await TelemetryReporter . create ( options ) ;
91
92
const sendStub = sandbox . stub ( reporter . getTelemetryClient ( ) , 'trackException' ) . callsFake ( ( ) => { } ) ;
@@ -95,7 +96,7 @@ describe('TelemetryReporter', () => {
95
96
} ) ;
96
97
97
98
it ( 'should not send a telemetry trace when disabled' , async ( ) => {
98
- sandbox . stub ( ConfigAggregator . prototype , 'getPropertyValue ' ) . returns ( 'true' ) ;
99
+ sandbox . stub ( enabledStubs , 'isEnabled ' ) . resolves ( false ) ;
99
100
const options = { project, key } ;
100
101
const reporter = await TelemetryReporter . create ( options ) ;
101
102
const sendStub = sandbox . stub ( reporter . getTelemetryClient ( ) , 'trackTrace' ) . callsFake ( ( ) => { } ) ;
@@ -105,7 +106,7 @@ describe('TelemetryReporter', () => {
105
106
} ) ;
106
107
107
108
it ( 'should not send a telemetry metric when disabled' , async ( ) => {
108
- sandbox . stub ( ConfigAggregator . prototype , 'getPropertyValue ' ) . returns ( 'true' ) ;
109
+ sandbox . stub ( enabledStubs , 'isEnabled ' ) . resolves ( false ) ;
109
110
const options = { project, key } ;
110
111
const reporter = await TelemetryReporter . create ( options ) ;
111
112
const sendStub = sandbox . stub ( reporter . getTelemetryClient ( ) , 'trackMetric' ) . callsFake ( ( ) => { } ) ;
@@ -115,7 +116,7 @@ describe('TelemetryReporter', () => {
115
116
} ) ;
116
117
117
118
it ( 'should log to enable telemetry metric when disabled' , async ( ) => {
118
- sandbox . stub ( ConfigAggregator . prototype , 'getPropertyValue ' ) . returns ( 'true' ) ;
119
+ sandbox . stub ( enabledStubs , 'isEnabled ' ) . resolves ( false ) ;
119
120
const warn = sandbox . stub ( ) ;
120
121
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
121
122
sandbox . stub ( Logger , 'child' ) . resolves ( { warn, debug : sandbox . stub ( ) } as any ) ;
0 commit comments