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