Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Jul 7, 2017
1 parent a073f61 commit fc2bc5a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
repo_token: w9HmlMl9558e1LpP9p62YgYutkVE9PqtN
repo_token: K4pavPyoEIHgj3bxfghHu2YmA8aqrnAnA
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![npm (tag)](https://img.shields.io/npm/v/local-web-server/next.svg)](https://www.npmjs.org/package/local-web-server)
[![npm module downloads](https://img.shields.io/npm/dt/local-web-server.svg)](https://www.npmjs.org/package/local-web-server)
[![Build Status](https://travis-ci.org/lwsjs/local-web-server.svg?branch=next)](https://travis-ci.org/lwsjs/local-web-server)
[![Dependency Status](https://david-dm.org/lwsjs/local-web-server/next.svg)](https://david-dm.org/lwsjs/local-web-server/next)
[![Coverage Status](https://coveralls.io/repos/github/lwsjs/local-web-server/badge.svg?branch=next)](https://coveralls.io/github/lwsjs/local-web-server?branch=next)[![Dependency Status](https://david-dm.org/lwsjs/local-web-server/next.svg)](https://david-dm.org/lwsjs/local-web-server/next)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
[![Join the chat at https://gitter.im/lwsjs/local-web-server](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lwsjs/local-web-server?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down
2 changes: 1 addition & 1 deletion lib/command/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class WsServe extends ServeCommand {
moduleDir: path.resolve(__dirname, `../../node_modules`),
modulePrefix: 'lws-'
}
super.execute(options, argv)
return super.execute(options, argv)
}

usage () {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"test": "test-runner test/*.js",
"docs": "jsdoc2md -t jsdoc2md/api.hbs -p list lib/*.js > doc/api.md; echo",
"cover": "istanbul cover ./node_modules/.bin/tape test/*.js && cat coverage/lcov.info | coveralls && rm -rf coverage; echo"
"cover": "istanbul cover ./node_modules/.bin/test-runner test/*.js && cat coverage/lcov.info | coveralls"
},
"repository": "https://github.com/lwsjs/local-web-server",
"author": "Lloyd Brookes <75pound@gmail.com>",
Expand All @@ -49,6 +49,8 @@
"lws-static": "^0.3.4"
},
"devDependencies": {
"coveralls": "^2.13.1",
"req-then": "^0.6.4",
"test-runner": "^0.4.0"
}
}
49 changes: 49 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const TestRunner = require('test-runner')
const a = require('assert')
const CliApp = require('../lib/cli-app')
const request = require('req-then')
const usage = require('lws/lib/usage')
usage.disable()

const runner = new TestRunner()

runner.test('cli.run', async function () {
const port = 7500 + this.index
const origArgv = process.argv.slice()
process.argv = [ 'node', 'something', '--port', `${port}` ]
const server = CliApp.run()
process.argv = origArgv
const response = await request(`http://127.0.0.1:${port}/`)
server.close()
a.strictEqual(response.res.statusCode, 200)
})

runner.test('cli.run: bad option', async function () {
const port = 7500 + this.index
const origArgv = process.argv.slice()
process.argv = [ 'node', 'something', '--should-fail' ]
const server = CliApp.run()
process.argv = origArgv
a.strictEqual(server, undefined)
})

runner.test('cli.run: --help', async function () {
const origArgv = process.argv.slice()
process.argv = [ 'node', 'something', '--help' ]
CliApp.run()
process.argv = origArgv
})

runner.test('cli.run: --version', async function () {
const origArgv = process.argv.slice()
process.argv = [ 'node', 'something', '--version' ]
CliApp.run()
process.argv = origArgv
})

runner.test('cli.run: middleware-list', async function () {
const origArgv = process.argv.slice()
process.argv = [ 'node', 'something', 'middleware-list' ]
CliApp.run()
process.argv = origArgv
})

0 comments on commit fc2bc5a

Please sign in to comment.