Skip to content

Commit ace957f

Browse files
committed
test: remove newly introduced chai tests
1 parent 94fb1a7 commit ace957f

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

packages/datadog-plugin-ws/test/index.spec.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
const assert = require('node:assert')
44
const { once } = require('node:events')
5-
const { expect } = require('chai')
65

76
const { after, afterEach, before, beforeEach, describe, it } = require('mocha')
87

98
const agent = require('../../dd-trace/test/plugins/agent')
109
const { withVersions } = require('../../dd-trace/test/setup/mocha')
10+
const { assertObjectContains } = require('../../../integration-tests/helpers')
1111
describe('Plugin', () => {
1212
let WebSocket
1313
let wsServer
@@ -447,17 +447,23 @@ describe('Plugin', () => {
447447
assert.ok(pointerLink, 'Should have a span pointer link')
448448
didFindPointerLink = true
449449

450-
expect(pointerLink.attributes).to.have.property('ptr.kind', 'websocket')
451-
expect(pointerLink.attributes).to.have.property('ptr.dir', 'd')
452-
expect(pointerLink.attributes).to.have.property('ptr.hash')
453-
expect(pointerLink.attributes).to.have.property('link.name', 'span-pointer-down')
454-
expect(pointerLink.attributes['ptr.hash']).to.be.a('string')
455-
expect(pointerLink.attributes['ptr.hash']).to.have.lengthOf(57)
450+
assertObjectContains(pointerLink, {
451+
attributes: {
452+
'ptr.kind': 'websocket',
453+
'ptr.dir': 'd',
454+
'link.name': 'span-pointer-down'
455+
}
456+
})
457+
didFindPointerLink = true
458+
459+
const { attributes } = pointerLink
460+
assert.ok(Object.hasOwn(attributes, 'ptr.hash'))
456461
// Hash format: <prefix><32 hex trace id><16 hex span id><8 hex counter>
457-
expect(pointerLink.attributes['ptr.hash']).to.match(/^[SC][0-9a-f]{32}[0-9a-f]{16}[0-9a-f]{8}$/)
462+
assert.match(attributes['ptr.hash'], /^[SC][0-9a-f]{32}[0-9a-f]{16}[0-9a-f]{8}$/)
463+
assert.strictEqual(attributes['ptr.hash'].length, 57)
458464
})
459465

460-
expect(didFindPointerLink).to.be.true
466+
assert.strictEqual(didFindPointerLink, true)
461467
})
462468

463469
it('should add span pointers to consumer spans', async () => {
@@ -484,20 +490,24 @@ describe('Plugin', () => {
484490
const pointerLink = spanLinks.find(link =>
485491
link.attributes && link.attributes['dd.kind'] === 'span-pointer'
486492
)
487-
assert.ok(pointerLink, 'Should have a span pointer link')
493+
494+
assertObjectContains(pointerLink, {
495+
attributes: {
496+
'ptr.kind': 'websocket',
497+
'ptr.dir': 'u',
498+
'link.name': 'span-pointer-up'
499+
}
500+
})
488501
didFindPointerLink = true
489502

490-
expect(pointerLink.attributes).to.have.property('ptr.kind', 'websocket')
491-
expect(pointerLink.attributes).to.have.property('ptr.dir', 'u')
492-
expect(pointerLink.attributes).to.have.property('ptr.hash')
493-
expect(pointerLink.attributes).to.have.property('link.name', 'span-pointer-up')
494-
expect(pointerLink.attributes['ptr.hash']).to.be.a('string')
495-
expect(pointerLink.attributes['ptr.hash']).to.have.lengthOf(57)
503+
const { attributes } = pointerLink
504+
assert.ok(Object.hasOwn(attributes, 'ptr.hash'))
496505
// Hash format: <prefix><32 hex trace id><16 hex span id><8 hex counter>
497-
expect(pointerLink.attributes['ptr.hash']).to.match(/^[SC][0-9a-f]{32}[0-9a-f]{16}[0-9a-f]{8}$/)
506+
assert.match(attributes['ptr.hash'], /^[SC][0-9a-f]{32}[0-9a-f]{16}[0-9a-f]{8}$/)
507+
assert.strictEqual(attributes['ptr.hash'].length, 57)
498508
})
499509

500-
expect(didFindPointerLink).to.be.true
510+
assert.strictEqual(didFindPointerLink, true)
501511
})
502512

503513
it('should generate unique hashes for each message', () => {

0 commit comments

Comments
 (0)