Skip to content

Commit

Permalink
fix content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Mar 13, 2017
1 parent 265d401 commit 6051d0f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,13 @@
module.exports = {
"extends": "es5",
"env": {
"browser": true,
"node": true,
"mocha": true
}
"plugins": [
"standard",
"promise",
"mocha"
]
};
4 changes: 4 additions & 0 deletions fixtures/shellhubrc.json
Expand Up @@ -14,6 +14,10 @@
"/deep/cwd": {
"cwd": "foo/bar",
"cmd": "echo nothing"
},
"/spawn": {
"cwd": "./",
"cmd": "echo spawning child process && sh hello-world.sh"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/server.js
Expand Up @@ -11,6 +11,7 @@ function controller(req, res) {
var pathname = url.parse(req.url).pathname;
var entry = config.scripts[pathname];

res.setHeader('content-type', 'text/plain')
if (!entry) {
var msg = 'path ' + pathname + ' not registered';
log(msg);
Expand Down
22 changes: 17 additions & 5 deletions test/server.js
@@ -1,8 +1,6 @@
const chai = require("chai");
const expect = chai.expect;
const request = require('supertest');
const server = require('../src/server.js');
const Config = require('../src/config.js');
var request = require('supertest');
var server = require('../src/server.js');
var Config = require('../src/config.js');

describe('server', function() {
var config = Config.load('fixtures/shellhubrc.json');
Expand All @@ -12,6 +10,13 @@ describe('server', function() {
return request(app).get('/foo').expect(404);
});

it('should respond with text/plain', function() {
return request(app)
.get('/hello/world')
.expect(200)
.expect('content-type', 'text/plain');
});

it('should respond with stdout', function() {
return request(app)
.get('/hello/world')
Expand All @@ -25,4 +30,11 @@ describe('server', function() {
.expect(200)
.expect(/first line\nsecond line\nthird line/);
});

it('should capture child outputs', function() {
return request(app)
.get('/spawn')
.expect(200)
.expect(/spawning child process\nhello world/);
});
});

0 comments on commit 6051d0f

Please sign in to comment.