Skip to content

Commit

Permalink
Fix some other race conditions in long-polling specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioschneider committed Oct 22, 2015
1 parent a6e494d commit 04329a1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/agent/plugins/control-panel/long-polling/test/index_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,14 @@ describe('long-polling', function() {

describe('and valid command object', function() {
it('emmits command', function() {
var command = {command: 'get', target: 'location'};
var command = {command: 'get', target: 'location'},
responses = 0;

server_up(function(req, res) {
res.statusCode = 200;
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify([command]));
if (responses) return server_down();
res.statusCode = 302;
res.end();
responses++;
});

load(function(err, em, spy) {
Expand Down Expand Up @@ -178,10 +181,13 @@ describe('long-polling', function() {

it('triggers error', function() {
var command = {command: 'get', target: 'location'};
responses = 0;

server_up(function(req, res) {
res.statusCode = 200;
res.writeHead(200, {'Content-Type': 'application/json'});
res.end('simon says: start alarm');
if (responses) return server_down();
res.statusCode = 302;
res.end();
responses++;
});

load(function(err, em, spy) {
Expand Down

0 comments on commit 04329a1

Please sign in to comment.