|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const assert = require('assert'); |
| 4 | +const request = require('supertest'); |
| 5 | +const config = require('./fixtures/simple-config/webpack.config'); |
| 6 | +const helper = require('./helper'); |
| 7 | + |
| 8 | +describe('socket options', () => { |
| 9 | + let server; |
| 10 | + let req; |
| 11 | + |
| 12 | + afterEach((done) => { |
| 13 | + helper.close(done); |
| 14 | + req = null; |
| 15 | + server = null; |
| 16 | + }); |
| 17 | + describe('default behavior', () => { |
| 18 | + beforeEach((done) => { |
| 19 | + server = helper.start(config, {}, done); |
| 20 | + req = request('http://localhost:8080'); |
| 21 | + }); |
| 22 | + |
| 23 | + it('defaults to a path', () => { |
| 24 | + assert.ok(server.sockPath.match(/\/[a-z0-9\-/]+[^/]$/)); |
| 25 | + }); |
| 26 | + |
| 27 | + it('responds with a 200', (done) => { |
| 28 | + req.get('/sockjs-node').expect(200, done); |
| 29 | + }); |
| 30 | + }); |
| 31 | + |
| 32 | + describe('socksPath option', () => { |
| 33 | + const path = '/foo/test/bar'; |
| 34 | + beforeEach((done) => { |
| 35 | + server = helper.start(config, { |
| 36 | + sockPath: '/foo/test/bar/' |
| 37 | + }, done); |
| 38 | + req = request('http://localhost:8080'); |
| 39 | + }); |
| 40 | + |
| 41 | + it('sets the sock path correctly and strips leading and trailing /s', () => { |
| 42 | + assert.equal(server.sockPath, path); |
| 43 | + }); |
| 44 | + |
| 45 | + it('responds with a 200 second', (done) => { |
| 46 | + req.get(path).expect(200, done); |
| 47 | + }); |
| 48 | + }); |
| 49 | +}); |
0 commit comments