Lloyd Brookes
6 years ago
8 changed files with 74 additions and 51 deletions
-
2index.js
-
2lib/cli-app.js
-
40package-lock.json
-
4package.json
-
2test/api.js
-
37test/cli.js
-
3test/fixture/middleware/index.js
-
35test/sequential.js
@ -0,0 +1,3 @@ |
|||
class TestMiddleware {} |
|||
|
|||
module.exports = TestMiddleware |
@ -0,0 +1,35 @@ |
|||
const Tom = require('test-runner').Tom |
|||
const fetch = require('node-fetch') |
|||
const LocalWebServer = require('../') |
|||
const WsCli = require('../lib/cli-app') |
|||
const a = require('assert') |
|||
|
|||
const tom = module.exports = new Tom('sequential', { concurrency: 1 }) |
|||
|
|||
let origCwd = '' |
|||
|
|||
tom.test('before', async function () { |
|||
origCwd = process.cwd() |
|||
process.chdir('test/fixture/middleware') |
|||
}) |
|||
|
|||
tom.test('cli: middleware named "index.js"', async function () { |
|||
let logMsg = '' |
|||
const cli = new WsCli({ log: function (msg) { logMsg = msg } }) |
|||
const lws = cli.start([ '--stack', 'index.js', '--config' ]) |
|||
a.ok(/TestMiddleware/.test(logMsg)) |
|||
}) |
|||
|
|||
tom.test('basic', async function () { |
|||
const port = 9100 + this.index |
|||
const ws = LocalWebServer.create({ |
|||
port: port, |
|||
stack: 'index.js' |
|||
}) |
|||
ws.server.close() |
|||
a.strictEqual(ws.stack[0].constructor.name, 'TestMiddleware') |
|||
}) |
|||
|
|||
tom.test('after', async function () { |
|||
process.chdir(origCwd) |
|||
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue