You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
650 B

9 years ago
  1. 'use strict'
  2. const test = require('tape')
  3. const request = require('req-then')
  4. const LocalWebServer = require('../../')
  5. const c = require('../common')
  6. test('logging', function (t) {
  7. t.plan(2)
  8. const ws = new LocalWebServer()
  9. const stream = require('stream').PassThrough()
  10. stream.on('readable', () => {
  11. let chunk = stream.read()
  12. if (chunk) t.ok(/GET/.test(chunk.toString()))
  13. })
  14. ws.addLogging('common', { stream: stream })
  15. const server = ws.getServer()
  16. server.listen(8100, () => {
  17. request('http://localhost:8100/')
  18. .then(c.checkResponse(t, 404))
  19. .then(server.close.bind(server))
  20. .catch(c.fail(t))
  21. })
  22. })