Created
June 4, 2010 17:27
-
-
Save robotarmy/425695 to your computer and use it in GitHub Desktop.
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
var http = require('http'); | |
exports.test_ = function(test){ | |
var client = http.createClient(7001, 'localhost'); | |
var jpost = {name:'A Thing', value: "A Value"}; | |
var request = client.request('POST', '/?callback=json_test_data&json='+JSON.stringify(jpost) ,{'host': 'localhost'}); | |
request.addListener('response', function (response) { | |
response.setEncoding('utf8'); | |
expect(response.statusCode).toEqual(200); | |
ok(response.headers["content-type"] == 'application/json;charset=utf-8', 'content-type set'); | |
ok(response.headers["Access-Control-Allow-Origin"] != undefined, 'Access-Control-Allow-Origin exists'); | |
response.addListener('data', function (chunk) { | |
}); | |
test.done(); | |
}); | |
request.end(); | |
}; |
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
#!/usr/local/bin/node | |
require.paths.push(__dirname); | |
require.paths.push(__dirname + '/deps'); | |
require.paths.push(__dirname + '/lib'); | |
require('Ledger'); | |
require('LedgerService'); | |
require('mongodb'); | |
try { | |
var testrunner = require('nodeunit').testrunner; | |
} | |
catch(e) { | |
var sys = require('sys'); | |
sys.puts("Cannot find nodeunit module."); | |
sys.puts("You can download submodules for this project by doing:"); | |
sys.puts(""); | |
sys.puts(" git submodule init"); | |
sys.puts(" git submodule update"); | |
sys.puts(""); | |
process.exit(); | |
} | |
process.chdir(__dirname); | |
testrunner.run(['test']); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment