Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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();
};
#!/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