Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50663 views
1
/*
2
* ecstatic-test.js: Tests for flatiron app(s) using the ecstatic plugin
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var assert = require('assert'),
10
fs = require('fs'),
11
path = require('path'),
12
request = require('request'),
13
resourceful = require('ecstatic'),
14
vows = require('vows');
15
16
var appDir = path.join(__dirname, '..', '..', 'examples', 'ecstatic-app'),
17
app = require(path.join(appDir, 'app'));
18
19
vows.describe('flatiron/plugins/ecstatic').addBatch({
20
"A flatiron app using `flatiron.plugins.ecstatic": {
21
topic: app,
22
"should extend the app correctly": function (app) {
23
assert.isString(app._ecstaticDir);
24
assert.isFunction(app.static);
25
assert.isFunction(app.http.before[0]);
26
assert.equal(app.http.before[0].length, 3);
27
},
28
"when the application is running": {
29
topic: function () {
30
app.start(8080, this.callback)
31
},
32
"a GET to /": {
33
topic: function () {
34
request('http://localhost:8080/headers', this.callback);
35
},
36
"should respond with JSON headers": function (err, res, body) {
37
assert.isNull(err);
38
assert.equal(res.statusCode, 200);
39
assert.isObject(JSON.parse(body));
40
}
41
},
42
"a GET to /style.css": {
43
topic: function () {
44
request('http://localhost:8080/style.css', this.callback);
45
},
46
"should respond with JSON headers": function (err, res, body) {
47
assert.isNull(err);
48
assert.equal(res.statusCode, 200);
49
50
assert.equal(
51
fs.readFileSync(path.join(appDir, 'app', 'assets', 'style.css'), 'utf8'),
52
body
53
);
54
}
55
}
56
}
57
}
58
}).export(module);
59
60