Skip to content

Commit

Permalink
test: add smoke test for bankai start
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Sep 4, 2016
1 parent 964fed3 commit 94a832d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"dependency-check": "^2.6.0",
"is-html": "^1.0.0",
"istanbul": "^0.4.4",
"openport": "0.0.4",
"standard": "^8.0.0",
"tape": "^4.6.0"
},
Expand Down
47 changes: 46 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
'use strict'

const childProcess = require('child_process')
const getPort = require('get-server-port')
const browserify = require('browserify')
const concat = require('concat-stream')
const openport = require('openport')
const isHtml = require('is-html')
const bankai = require('../')
const http = require('http')
const path = require('path')
const test = require('tape')
const bankai = require('../')

test('html', function (t) {
t.test('returns data', function (t) {
Expand Down Expand Up @@ -85,6 +89,30 @@ test('js', function (t) {
})
})

test('start', function (t) {
t.test('start does not throw', function (t) {
t.plan(1)

openport.find(function (err, p) {
const port = err ? 1337 : p

const args = ['start', '--entry=./fixture', `--port=${port}`]

bin(args, function (error, data, child) {
child.kill()

if (error) {
return t.fail(error)
}

const actual = data.toString().split('\n')[0]
const expected = `Started bankai for fixture.js on http://localhost:${port}`
t.equal(actual, expected, 'start logs success')
})
})
})
})

test('__END__', function (t) {
t.on('end', function () {
setTimeout(function () {
Expand All @@ -93,3 +121,20 @@ test('__END__', function (t) {
})
t.end()
})

function bin (args, cb) {
const file = path.resolve(__dirname, '../bin/index.js')

const child = childProcess.spawn(file, args, {
cwd: __dirname,
env: process.env
})

child.stdout.once('data', function (data) {
cb(null, data, child)
})

child.stderr.once('data', function (error) {
cb(new Error(error), null, child)
})
}

0 comments on commit 94a832d

Please sign in to comment.