|
| 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(helper.close); |
| 13 | + |
| 14 | + describe('default behavior', () => { |
| 15 | + const defaultPath = '/sockjs-node'; |
| 16 | + before((done) => { |
| 17 | + server = helper.start(config, {}, done); |
| 18 | + req = request(server.app); |
| 19 | + }); |
| 20 | + |
| 21 | + it('defaults to a path', () => { |
| 22 | + assert.equal(server.sockPath, defaultPath); |
| 23 | + }); |
| 24 | + |
| 25 | + it('responds', (done) => { |
| 26 | + req.get(defaultPath) |
| 27 | + .expect(200) |
| 28 | + .end((err) => { |
| 29 | + if (err) { |
| 30 | + done(err); |
| 31 | + } |
| 32 | + done(); |
| 33 | + }); |
| 34 | + }); |
| 35 | + }); |
| 36 | + |
| 37 | + describe('socksPath option', () => { |
| 38 | + const path = '/foo/test/bar'; |
| 39 | + before((done) => { |
| 40 | + server = helper.start(config, { |
| 41 | + sockPath: '/foo/test/bar/' |
| 42 | + }, done); |
| 43 | + req = request(server.app); |
| 44 | + }); |
| 45 | + |
| 46 | + it('correctly sets the servers sockPath including removal of extraneous slashes', () => { |
| 47 | + assert.equal(path, server.sockPath); |
| 48 | + }); |
| 49 | + |
| 50 | + it('responds', (done) => { |
| 51 | + req.get(path) |
| 52 | + .expect(200) |
| 53 | + .end((err) => { |
| 54 | + if (err) { |
| 55 | + done(err); |
| 56 | + } |
| 57 | + done(); |
| 58 | + }); |
| 59 | + }); |
| 60 | + }); |
| 61 | +}); |
0 commit comments