Setup more app tests

This commit is contained in:
Björn Dahlgren 2018-12-02 23:06:48 +01:00
parent be8d3f6cdd
commit be5174ebb2
4 changed files with 50 additions and 7 deletions

View File

@ -17,3 +17,4 @@ before_install:
script:
- npm run lint
- npm test
- ./node_modules/.bin/webpack

18
app.js
View File

@ -19,12 +19,6 @@ var app = express()
var server = require('http').Server(app)
var io = require('socket.io')(server)
var webpackCompiler = webpack(webpackConfig)
app.use(webpackMiddleware(webpackCompiler, {
publicPath: webpackConfig.output.publicPath
}))
setupBasicAuth(config, app)
app.use(bodyParser.json())
@ -71,4 +65,14 @@ manager.on('servers', function () {
io.emit('servers', manager.getServers())
})
server.listen(config.port, config.host)
if (require.main === module) {
var webpackCompiler = webpack(webpackConfig)
app.use(webpackMiddleware(webpackCompiler, {
publicPath: webpackConfig.output.publicPath
}))
server.listen(config.port, config.host)
}
module.exports = app

View File

@ -58,6 +58,7 @@
"mocha": "~3.2.0",
"should": "~13.0.1",
"standard": "^14.3.1",
"supertest": "^2.0.1",
"timekeeper": "0.0.5"
}
}

37
test/app.js Normal file
View File

@ -0,0 +1,37 @@
const request = require('supertest')
const app = require('../app')
function requestPath (path, contentType, done) {
request(app)
.get(path)
.expect('Content-Type', contentType)
.expect(200)
.end(done)
}
describe('App', function () {
it('should serve main page', function (done) {
requestPath('/', /html/, done)
})
it('should serve logs', function (done) {
requestPath('/api/logs', /json/, done)
})
it('should serve missions', function (done) {
requestPath('/api/missions', /json/, done)
})
it('should serve mods', function (done) {
requestPath('/api/mods', /json/, done)
})
it('should serve servers', function (done) {
requestPath('/api/servers', /json/, done)
})
it('should serve settings', function (done) {
requestPath('/api/settings', /json/, done)
})
})