UNPKG

apeman-app-json

Version:
58 lines (52 loc) 1.51 kB
/** * Test case for create. * Runs with nodeunit. */ var create = require('../lib/create.js'), freeport = require('freeport'), apemanApp = require('apeman-app'), request = require('request'); exports.setUp = function (done) { done(); }; exports.tearDown = function (done) { done(); }; exports['Create an app.'] = function (test) { var app = create({}); test.ok(app); freeport(function (err, port) { test.ifError(err); apemanApp('testing-app', { configuration: { $apps: { 'testing-app': { '/': [ app, function (req, res) { res.json({ success: true }) } ] } } }, port: port }, function (err, server) { test.ifError(err); request('http://localhost:' + port + '/', function (err, res, body) { test.ifError(err); test.equal(res.statusCode, 200); var data; test.doesNotThrow(function () { data = JSON.parse(body); }); test.ok(data); test.ok(data.success); server.close(); test.done(); }); }); }); };