Created
September 9, 2014 14:46
-
-
Save ravinggenius/eb233d8e7d2ca8a31ea3 to your computer and use it in GitHub Desktop.
This file contains 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
var Hapi = require('hapi'); | |
var server = new Hapi.Server('localhost', 5000); | |
server.route({ | |
method: 'GET', | |
path: '/', | |
handler: function (request, reply) { | |
reply('hello world'); | |
} | |
}); | |
module.exports = server; |
This file contains 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
{ | |
"name": "hapi-mocha", | |
"version": "1.0.0", | |
"description": "Simple app to demonstrate Hapi and Mocha issue", | |
"main": "index.js", | |
"scripts": { | |
"test": "mocha" | |
}, | |
"author": "Thomas Ingram", | |
"license": "MIT", | |
"dependencies": { | |
"hapi": "^6.8.0" | |
}, | |
"devDependencies": { | |
"mocha": "^1.21.4" | |
} | |
} |
This file contains 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
var assert = require('assert'); | |
var server = require('./index'); | |
describe('GET /', function () { | |
var request = { | |
method: 'GET', | |
url: '/' | |
}; | |
it('just works', function (done) { | |
server.inject(request, function (response) { | |
assert(response.payload === 'hello world'); | |
done(); | |
}); | |
}); | |
it('times out', function (done) { | |
server.inject(request, function (response) { | |
assert(response.payload === 'hello-world'); | |
done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment