Skip to content

Commit

Permalink
refs #5 - choose a testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
opensas committed Mar 18, 2013
1 parent c2fa914 commit 1f49c1d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
7 changes: 7 additions & 0 deletions webservice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ and then browse to:
Congrats! You have (this VERY PRELIMINAR version of) ideas working!

Now go ahead and have a look at the code.

# Testing

Install jasmine-node

npm install jasmine-node -g

1 change: 1 addition & 0 deletions webservice/controllers/ping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

exports.ping = function(req, res, next) {

console.log('got pinged! at', (new Date()).toString());
res.send({
message: "Hi, I'm alive",
date: new Date()
Expand Down
33 changes: 33 additions & 0 deletions webservice/tests/basic/test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

// it("should respond with hello world", function(done) {
// request("http://localhost:3000/hello", function(error, response, body){
// expect(body).toEqual("hello world");
// done();
// });
// });

describe('jasmine-node', function(){

it('should pass', function(){
expect(1+2).toEqual(3);
});

it('shows asynchronous test', function(){
setTimeout(function(){
expect('second').toEqual('second');
asyncSpecDone();
}, 1);
expect('first').toEqual('first');
asyncSpecWait();
});

it('shows asynchronous test node-style', function(done){
setTimeout(function(){
expect('second').toEqual('second');
// If you call done() with an argument, it will fail the spec
// so you can use it as a handler for many async node calls
done();
}, 1);
expect('first').toEqual('first');
});
});
26 changes: 26 additions & 0 deletions webservice/tests/ping/ping.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

// it("should respond with hello world", function(done) {
// request("http://localhost:3000/hello", function(error, response, body){
// expect(body).toEqual("hello world");
// done();
// });
// });

var request = require('http'),
url = 'http://localhost:1337/';

describe('webservice', function() {

it('should respond to /ping', function(done) {
console.log('x');
request.get(url + 'ping', function(res) {
// console.log(res.statusCode);
console.log(res);
expect(res.statusCode).toBe(200);
done();
});

});

});

17 changes: 17 additions & 0 deletions webservice/tests/test2.spec.coffee.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
request = require('http')

url = 'http://localhost:1337/'

describe 'jasmine-node', ->

it 'should pass', ->
console.log('testing from coffee')
expect(1+2).toEqual(4)

describe 'webservice', ->

it 'should respond to /ping', (done) ->
request.get url + 'ping', (res) ->
expect res.statusCode toBe 200
done()

0 comments on commit 1f49c1d

Please sign in to comment.