Commit d859b7d1 authored by antirek's avatar antirek

fix tests

parent d28556a7
......@@ -10,7 +10,7 @@ var agi = function (handler) {
};
var start = function (port) {
server = require('net').createServer(handle).listen(port);
return require('net').createServer(handle).listen(port);
};
return {
......
var MemoryStream = require('memorystream');
var agi = require('./../lib')
var expect = require('expect.js');
var Context = agi.Context;
var state = agi.state;
var Context = require('./../lib/context');
var state = require('./../lib/state');
//helpers
var writeVars = function(stream) {
......@@ -503,15 +503,15 @@ describe('Context', function() {
describe('agi#createServer', function() {
it('returns instance of net.Server', function() {
var net = require('net');
var server = agi.createServer();
var server = (new agi()).start(3000);
expect(server instanceof net.Server).ok();
});
it('invokes callback when a new connection is established', function(done) {
var server = agi.createServer(function(context) {
expect(context instanceof agi.Context);
var server = new agi(function(context) {
expect(context instanceof Context);
done();
});
}).start(3000);
server.emit('connection', new MemoryStream());
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment