Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed May 2, 2024
1 parent c8e9e1c commit d893bce
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/net_utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const assert = require('node:assert')
const EventEmitter = require('node:events');
const os = require('node:os')
const path = require('node:path')

Expand Down Expand Up @@ -534,3 +535,28 @@ describe('on_local_interface', function () {
done()
})
})

describe('add_line_processor', function () {
beforeEach(function (done) {
this.net_utils = require('../index')
this.net_utils.config = this.net_utils.config.module_config(
path.resolve('test'),
)
done()
})

it('adds a line processor', function (done) {
const socket = new EventEmitter()
let lines = 0
socket.on('line', () => {
lines++
})
socket.on('end', (e) => {

Check failure on line 554 in test/net_utils.js

View workflow job for this annotation

GitHub Actions / lint / lint

'e' is defined but never used

Check failure on line 554 in test/net_utils.js

View workflow job for this annotation

GitHub Actions / lint / lint

'e' is defined but never used
assert.equal(lines, 3)
done()
})
this.net_utils.add_line_processor(socket)
socket.emit('data', `multi\nline\nallThisDataIsLost\n`)
socket.emit('end')
})
})

0 comments on commit d893bce

Please sign in to comment.