Skip to content

Commit

Permalink
add sockpath tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trescenzi committed Oct 31, 2018
1 parent c0faeeb commit bd31f5a
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test/Socket.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'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(helper.close);

describe('default behavior', () => {
const defaultPath = '/sockjs-node';
before((done) => {
server = helper.start(config, {}, done);
req = request(server.app);
});

it('defaults to a path', () => {
assert.equal(server.sockPath, defaultPath);
});

it('responds', (done) => {
req.get(defaultPath)
.expect(200)
.end((err) => {
if (err) {
done(err);
}
done();
});
});
});

describe('socksPath option', () => {
const path = '/foo/test/bar';
before((done) => {
server = helper.start(config, {
sockPath: '/foo/test/bar/'
}, done);
req = request(server.app);
});

it('correctly sets the servers sockPath including removal of extraneous slashes', () => {
assert.equal(path, server.sockPath);
});

it('responds', (done) => {
req.get(path)
.expect(200)
.end((err) => {
if (err) {
done(err);
}
done();
});
});
});
});

0 comments on commit bd31f5a

Please sign in to comment.