Created
January 14, 2016 14:48
-
-
Save yaacovCR/8804909179d80532512f to your computer and use it in GitHub Desktop.
Gulp: one way to close connections properly with gulp, jasmine-node and request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global describe:false, it:false, expect:false*/ | |
var request = require('request'); | |
var app = require('../app'); | |
var server = require('http').createServer(app); | |
var baseUrl = 'http://127.0.0.1:3000/example-route'; | |
describe('example-route', function() { | |
describe('app spinup', function() { | |
it('should be ok', function(done) { | |
server.listen(3000); | |
server.on('listening', function() { | |
app.connect(); | |
done(); | |
}); | |
}); | |
}); | |
describe('POST /', function() { | |
var requestOptions = { | |
url: baseUrl, | |
json : true, | |
body: { | |
stuff : { | |
innerStuff1 : '', | |
innerStuff2 : '' | |
} | |
} | |
}; | |
it('returns status code 404 as this route does not exist', function(done) { | |
requestOptions.body.stuff.innerStuff1 = 'dummyInnerStuff1'; | |
requestOptions.body.stuff.innerStuff2 = 'dummyInnerStuff2'; | |
request.post(requestOptions, function(error, response) { | |
expect(response.statusCode).toBe(404); | |
done(); | |
}); | |
}); | |
}); | |
describe('app spindown', function() { | |
it('should be ok', function(done) { | |
app.disconnect(); | |
server.close(); | |
done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment