arnaucube
arnaucube/socketioMEANseedPublic Self-hosted repository
socketioMEANseed/www/node_modules/union/test/ecstatic-test.js
www/node_modules/union/test/ecstatic-test.jsRaw
 1/*
 2 * simple-test.js: Simple tests for basic streaming and non-streaming HTTP requests with union.
 3 *
 4 * (C) 2011, Charlie Robbins & the Contributors
 5 * MIT LICENSE
 6 *
 7 */
 8
 9var assert = require('assert'),
10    ecstatic = require('ecstatic')(__dirname + '/fixtures/static'),
11    request = require('request'),
12    vows = require('vows'),
13    union = require('../');
14
15vows.describe('union/ecstatic').addBatch({
16  "When using union with ecstatic": {
17    topic: function () {
18      union.createServer({
19        before: [
20          ecstatic
21        ]
22      }).listen(18082, this.callback);
23    },
24    "a request to /some-file.txt": {
25      topic: function () {
26        request({ uri: 'http://localhost:18082/some-file.txt' }, this.callback);
27      },
28      "should respond with `hello world`": function (err, res, body) {
29        assert.isNull(err);
30        assert.equal(body, 'hello world\n');
31      }
32    },
33    "a request to /404.txt (which does not exist)": {
34      topic: function () {
35        request({ uri: 'http://localhost:18082/404.txt' }, this.callback);
36      },
37      "should respond with 404 status code": function (err, res, body) {
38        assert.isNull(err);
39        assert.equal(res.statusCode, 404);
40      }
41    }
42  }
43}).export(module);
44