-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sovattha Sok
committed
Jul 10, 2013
1 parent
d8c5781
commit 2b04475
Showing
4 changed files
with
57 additions
and
10 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var server = require('../app'), | ||
assert = require('assert'), | ||
http = require('http'); | ||
|
||
var SERVER_URL_FRAGMENT = 'http://localhost:'; | ||
var UNIT_TESTS_PORT = 8000; // Cannot be 80 | ||
|
||
describe('/', function () { | ||
it('should return 200', function (done) { | ||
server.listen(UNIT_TESTS_PORT); | ||
http.get(SERVER_URL_FRAGMENT + UNIT_TESTS_PORT, function (res) { | ||
assert.equal(200, res.statusCode); | ||
done(); | ||
}); | ||
}); | ||
|
||
pageContains('Sovattha Sok', '/'); | ||
pageContains('My videos', '/video'); | ||
|
||
function pageContains(word, uri) { | ||
it('should contain ' + word, function (done) { | ||
http.get(SERVER_URL_FRAGMENT + UNIT_TESTS_PORT + uri, function (res) { | ||
var data = ''; | ||
res.on('data', function (chunk) { | ||
data += chunk; | ||
}); | ||
res.on('end', function () { | ||
console.log('Found %s at index %s', word, data.indexOf(word)); | ||
assert.notEqual(data.indexOf(word), -1); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var http = require('http'); | ||
|
||
this.server = http.createServer(function (req, res) { | ||
console.log('Creating http server'); | ||
res.writeHead(200, { 'Content-Type': 'text/plain' }); | ||
res.end('Hello, world!\n'); | ||
}); | ||
|
||
exports.listen = function () { | ||
console.log('http server listening'); | ||
this.server.listen.apply(this.server, arguments); | ||
}; | ||
|
||
exports.close = function (callback) { | ||
console.log('http server closing'); | ||
this.server.close(callback); | ||
}; |
This file was deleted.
Oops, something went wrong.