Skip to content

Commit 76af6c8

Browse files
author
nicola
committed
adding mount params tests
1 parent ab3e6ec commit 76af6c8

2 files changed

Lines changed: 43 additions & 28 deletions

File tree

‎options.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ function params(argv) {
2121
opts.cert = argv.cert;
2222
opts.key = argv.key;
2323
opts.mount = argv.mount || '/';
24+
// Removing ending '/'
25+
if (opts.mount.length > 1 &&
26+
opts.mount[opts.mount.length - 1] === '/') {
27+
opts.mount = opts.mount.slice(0, -1);
28+
}
29+
2430
opts.verbose = argv.verbose;
2531
opts.webid = argv.webid;
2632

‎test/params.js‎

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,43 @@ function write (text, file) {
2525

2626
describe('params', function () {
2727

28-
describe('uri', function () {
29-
30-
// describe('not passed', function () {
31-
32-
// var ldp = ldnode.createServer({
33-
// base: __dirname
34-
// });
35-
// ldp.listen(3456);
36-
37-
// it('should be the proxy value if exist', function (done) {
38-
// done();
39-
// })
40-
41-
// it('should be localhost if no proxy', function (done) {
42-
// done();
43-
// })
44-
// })
45-
46-
// describe('passed', function() {
47-
// var ldp = ldnode.createServer({
48-
// uri: 'http://example.com',
49-
// base: __dirname
50-
// });
51-
// ldp.listen(3456);
52-
// it ('should not use proxy', function (done) {
53-
// done();
54-
// })
55-
// })
28+
describe('mount', function () {
29+
30+
describe('not passed', function () {
31+
it('should fallback on /', function (done) {
32+
var ldp = ldnode();
33+
assert.equal(ldp.locals.ldp.mount, '/');
34+
done();
35+
});
36+
37+
});
38+
39+
describe('passed', function() {
40+
it ('should properly set the opts.mount', function (done) {
41+
var ldp1 = ldnode({
42+
mount: '/'
43+
});
44+
assert.equal(ldp1.locals.ldp.mount, '/');
45+
46+
var ldp2 = ldnode({
47+
mount: '/test'
48+
});
49+
assert.equal(ldp2.locals.ldp.mount, '/test');
50+
51+
done();
52+
});
53+
it('should drop tha trailing /', function () {
54+
var ldp1 = ldnode({
55+
mount: '/test/'
56+
});
57+
assert.equal(ldp1.locals.ldp.mount, '/test');
58+
59+
var ldp2 = ldnode({
60+
mount: '/test/test'
61+
});
62+
assert.equal(ldp1.locals.ldp.mount, '/test');
63+
});
64+
});
5665
});
5766

5867
describe('root', function () {

0 commit comments

Comments
 (0)