Skip to content

Commit

Permalink
Simplify the sanity test check
Browse files Browse the repository at this point in the history
App doesn't need to listen in the test script as supertest accepts the
app variable and handles the listening and un-listening itself.

This also removes the needs for the after block to stop the server.
  • Loading branch information
gemmaleigh committed Nov 16, 2016
1 parent edf1f9b commit b7903ee
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions test/spec/sanity-checks.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
/* eslint-env mocha */

var request = require('supertest')
var assert = require('assert')
var app = require('../../server.js')
var path = require('path')
var fs = require('fs')
var assert = require('assert')

/**
* Basic sanity checks on the dev server
*/
describe('The prototype kit', function () {
var app
var server

before(function () {
app = require('../../server')
server = app.listen(3000)
})

after(function () {
server.close()
})

it('should generate assets into the /public folder', function () {
assert.doesNotThrow(function () {
fs.accessSync(path.resolve(__dirname, '../../public/javascripts/application.js'))
Expand All @@ -33,6 +21,13 @@ describe('The prototype kit', function () {
request(app)
.get('/')
.expect('Content-Type', /text\/html/)
.expect(200, done)
.expect(200)
.end(function (err, res) {
if (err) {
done(err)
} else {
done()
}
})
})
})

0 comments on commit b7903ee

Please sign in to comment.