Skip to content

Instantly share code, notes, and snippets.

@chrislaughlin
Created October 19, 2013 10:00
Show Gist options
  • Save chrislaughlin/7053939 to your computer and use it in GitHub Desktop.
Save chrislaughlin/7053939 to your computer and use it in GitHub Desktop.
Jasmine Tests
describe("Main Server Tests", function() {
var request = require('request');
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
expect(body).toEqual("Hello World");
done();
});
});
it("should respond 10 tweets based on a search query", function(done) {
request("http://localhost:3000/tweets/search?search=Belfast", function(error, response, body){
var tweets = JSON.parse(body);
expect(tweets.length).toEqual(10);
expect(tweets[0].text.toLowerCase().indexOf('belfast') != -1).toBeTruthy();
done();
});
request("http://localhost:3000/tweets/search?search=London", function(error, response, body){
var tweets = JSON.parse(body);
expect(tweets.length).toEqual(10);
expect(tweets[0].text.toLowerCase().indexOf('london') != -1).toBeTruthy();
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment