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.

36 lines
937 B

9 years ago
9 years ago
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. const path = require('path')
  7. test('stack', function (t) {
  8. t.plan(2)
  9. const ws = new LocalWebServer({
  10. stack: [ path.resolve(__dirname, 'test-middleware.js') ],
  11. port: 8100,
  12. ignoreCli: true
  13. })
  14. const server = ws.getServer(() => {
  15. return request('http://localhost:8100/')
  16. .then(c.checkResponse(t, 200, /1234512345/))
  17. .then(server.close.bind(server))
  18. .catch(c.fail(t))
  19. })
  20. })
  21. test('https', function (t) {
  22. t.plan(2)
  23. const ws = new LocalWebServer({
  24. stack: [ path.resolve(__dirname, 'test-middleware.js') ],
  25. https: true,
  26. port: 8100,
  27. ignoreCli: true
  28. })
  29. const server = ws.getServer(() => {
  30. return request('https://localhost:8100/')
  31. .then(c.checkResponse(t, 200, /1234512345/))
  32. .then(server.close.bind(server))
  33. })
  34. })