Browse Source

tests

master
Lloyd Brookes 8 years ago
parent
commit
fc2bc5a92a
  1. 2
      .coveralls.yml
  2. 2
      README.md
  3. 2
      lib/command/serve.js
  4. 4
      package.json
  5. 49
      test/cli.js

2
.coveralls.yml

@ -1 +1 @@
repo_token: w9HmlMl9558e1LpP9p62YgYutkVE9PqtN
repo_token: K4pavPyoEIHgj3bxfghHu2YmA8aqrnAnA

2
README.md

@ -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)

2
lib/command/serve.js

@ -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 () {

4
package.json

@ -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>",
@ -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
test/cli.js

@ -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
})
Loading…
Cancel
Save