Navigation Menu

Skip to content

Commit

Permalink
tests: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Aug 15, 2014
1 parent 2cea4d2 commit baba40f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/test.js
@@ -1,10 +1,11 @@

var assert = require('assert')
var fs = require('fs')
var net = require('net')

var destroy = require('..')

describe('Destroy', function () {
describe('destroy', function () {
it('should destroy a stream', function () {
var stream = fs.createReadStream('package.json')
assert(!isdestroyed(stream))
Expand All @@ -16,6 +17,10 @@ describe('Destroy', function () {
destroy()
})

it('should handle random object', function () {
destroy({})
})

describe('ReadStream', function () {
it('should not leak fd when called sync to open', function (done) {
// this test will timeout on a fd leak
Expand Down Expand Up @@ -51,6 +56,22 @@ describe('Destroy', function () {
done()
})
})

describe('Socket', function () {
it('should destroy a socket', function (done) {
var server = net.createServer(function (connection) {
socket.on('close', function () {
done()
})
destroy(connection)
})
var socket

server.listen(0, function () {
socket = net.connect(this.address().port)
})
})
})
})

function isdestroyed(stream) {
Expand Down

0 comments on commit baba40f

Please sign in to comment.