base tests

This commit is contained in:
David Dias 2015-07-10 22:02:57 -07:00
parent 30a754b92d
commit 1d0cc68645
4 changed files with 81 additions and 5 deletions

View File

@ -24,5 +24,8 @@
"bugs": { "bugs": {
"url": "https://github.com/diasdavid/abstract-stream-muxer/issues" "url": "https://github.com/diasdavid/abstract-stream-muxer/issues"
}, },
"homepage": "https://github.com/diasdavid/abstract-stream-muxer" "homepage": "https://github.com/diasdavid/abstract-stream-muxer",
"dependencies": {
"stream-pair": "^1.0.3"
}
} }

View File

@ -1,9 +1,51 @@
var streamPair = require('stream-pair')
module.exports.all = function (test, common) { module.exports.all = function (test, common) {
test('see if this works', function (t) {
common.setup(test, function (err, muxer) { test('Open a stream from the dealer', function (t) {
common.setup(test, function (err, Muxer) {
t.plan(4)
t.ifError(err, 'Should not throw') t.ifError(err, 'Should not throw')
// write test here
t.end() var pair = streamPair.create()
var dialer = new Muxer()
var listener = new Muxer()
var connDialer = dialer.attach(pair)
var connListener = listener.attach(pair.other)
connDialer.dialStream(function (err, stream) {
t.ifError(err, 'Should not throw')
t.pass('dialed stream')
})
connListener.on('stream', function (stream) {
t.pass('got stream')
})
}) })
}) })
test('Open a stream from the listener', function (t) {
common.setup(test, function (err, Muxer) {
t.plan(4)
t.ifError(err, 'Should not throw')
var pair = streamPair.create()
var dialer = new Muxer()
var listener = new Muxer()
var connDialer = dialer.attach(pair)
var connListener = listener.attach(pair.other)
connListener.dialStream(function (err, stream) {
t.ifError(err, 'Should not throw')
t.pass('dialed stream')
})
connDialer.on('stream', function (stream) {
t.pass('got stream')
})
})
})
} }

View File

@ -1,3 +1,4 @@
module.exports = function (test, common) { module.exports = function (test, common) {
require('./base-test.js').all(test, common) require('./base-test.js').all(test, common)
require('./stress-test.js').all(test, common)
} }

30
tests/stress-test.js Normal file
View File

@ -0,0 +1,30 @@
/* knobs - nStreams, nMsg, sizeMsg[low, high] */
var streamPair = require('stream-pair')
module.exports.all = function (test, common) {
test('Open a stream from the dealer', function (t) {
common.setup(test, function (err, Muxer) {
t.plan(4)
t.ifError(err, 'Should not throw')
var pair = streamPair.create()
var dialer = new Muxer()
var listener = new Muxer()
var connDialer = dialer.attach(pair)
var connListener = listener.attach(pair.other)
connDialer.dialStream(function (err, stream) {
t.ifError(err, 'Should not throw')
t.pass('dialed stream')
})
connListener.on('stream', function (stream) {
t.pass('got stream')
})
})
})
}