Skip to content

Commit

Permalink
No longer accepting a provided node server.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Gensler committed Sep 4, 2015
1 parent 055e856 commit 543c812
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/turbobreaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ export class TurboBreaker {
callback = config;
config = {};
}
this.server = config.httpServer;
if (!this.server) {
this.server = this.createServer(callback);
} else {
callback();
}
this.server = this.createServer(callback);
}

command(data) {
Expand Down
12 changes: 10 additions & 2 deletions test/turbobreaker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ test('creates an HTTP server', t => {
const turbo = new TurboBreaker(() => {
t.ok(turbo.server, 'has an internal server property');
t.ok(turbo.server instanceof http.Server, 'should be an instance of http.Server');
fetch('http://localhost:8080/').then((res) => {
fetch('http://127.0.0.1:8080/').then((res) => {
t.equal(res.status, 404, 'should respond with a 404');
t.end();
turbo.stop();
}, (e) => {
t.fail('Unknown error occured when fetching localhost.');
console.error(e.stack);
t.end();
});
});
});
Expand All @@ -41,7 +45,7 @@ test('emits a server-sent event via the "command" method', t => {
working: true
};
const turbo = new TurboBreaker(() => {
var es = new EventSource('http://localhost:8080/hystrix.stream');
var es = new EventSource('http://127.0.0.1:8080/hystrix.stream');
es.onmessage = function(e) {
t.deepEqual(JSON.parse(e.data), expected, 'data payload should be equal');
t.end();
Expand All @@ -61,4 +65,8 @@ test('emits a server-sent event via the "command" method', t => {
});

t.ok(turbo.command, 'TurboBreaker#command is defined');
});

test('should emit the same data to multiple connected clients', t => {
t.end();
});

0 comments on commit 543c812

Please sign in to comment.