Skip to content

Commit 635638d

Browse files
committed
Add test to check telemetry endpoints does not subscribe if it is not enabled
1 parent a426131 commit 635638d

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

packages/dd-trace/test/telemetry/endpoints.spec.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,29 @@ describe('endpoints telemetry', () => {
1313
const host = 'host'
1414

1515
describe('start', () => {
16-
it('should subscribe', () => {
17-
const subscribe = sinon.stub()
18-
const dc = { channel () { return { subscribe } } }
19-
const endpoints = proxyquire('../../src/telemetry/endpoints', {
20-
'dc-polyfill': dc
21-
})
16+
const subscribe = sinon.stub()
17+
const dc = { channel () { return { subscribe } } }
18+
const endpoints = proxyquire('../../src/telemetry/endpoints', {
19+
'dc-polyfill': dc
20+
})
21+
22+
beforeEach(() => {
23+
sinon.reset()
24+
})
2225

26+
it('should subscribe', () => {
2327
const config = { appsec: { apiSecurity: { endpointCollectionEnabled: true } } }
2428
endpoints.start(config)
2529

2630
expect(subscribe).to.have.been.calledOnce
2731
})
32+
33+
it('should not subscribe', () => {
34+
const config = { appsec: { apiSecurity: { endpointCollectionEnabled: false } } }
35+
endpoints.start(config)
36+
37+
expect(subscribe).to.not.have.been.called
38+
})
2839
})
2940

3041
describe('on events', () => {
@@ -84,7 +95,6 @@ describe('endpoints telemetry', () => {
8495

8596
expect(sendData).to.have.been.calledOnce
8697
const payload = sendData.firstCall.args[4]
87-
console.log(payload)
8898
expect(payload.endpoints).to.have.deep.members([
8999
{
90100
type: 'REST',

0 commit comments

Comments
 (0)