Commit d859b7d1 authored by antirek's avatar antirek

fix tests

parent d28556a7
...@@ -10,7 +10,7 @@ var agi = function (handler) { ...@@ -10,7 +10,7 @@ var agi = function (handler) {
}; };
var start = function (port) { var start = function (port) {
server = require('net').createServer(handle).listen(port); return require('net').createServer(handle).listen(port);
}; };
return { return {
......
var MemoryStream = require('memorystream'); var MemoryStream = require('memorystream');
var agi = require('./../lib') var agi = require('./../lib')
var expect = require('expect.js'); var expect = require('expect.js');
var Context = agi.Context; var Context = require('./../lib/context');
var state = agi.state; var state = require('./../lib/state');
//helpers //helpers
var writeVars = function(stream) { var writeVars = function(stream) {
...@@ -503,15 +503,15 @@ describe('Context', function() { ...@@ -503,15 +503,15 @@ describe('Context', function() {
describe('agi#createServer', function() { describe('agi#createServer', function() {
it('returns instance of net.Server', function() { it('returns instance of net.Server', function() {
var net = require('net'); var net = require('net');
var server = agi.createServer(); var server = (new agi()).start(3000);
expect(server instanceof net.Server).ok(); expect(server instanceof net.Server).ok();
}); });
it('invokes callback when a new connection is established', function(done) { it('invokes callback when a new connection is established', function(done) {
var server = agi.createServer(function(context) { var server = new agi(function(context) {
expect(context instanceof agi.Context); expect(context instanceof Context);
done(); done();
}); }).start(3000);
server.emit('connection', new MemoryStream()); 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