adapting scode eslint standard config
This commit is contained in:
154
test/main.js
154
test/main.js
@ -1,77 +1,77 @@
|
||||
const { describe, it, beforeEach } = require('mocha');
|
||||
const expect = require('chai').expect;
|
||||
|
||||
const requestor = require('../index');
|
||||
|
||||
const mock = {
|
||||
registered: {},
|
||||
post: function (path, handler) {
|
||||
this.registered['post-' + path] = handler;
|
||||
},
|
||||
get: function (path, handler) {
|
||||
this.registered['get-' + path] = handler;
|
||||
},
|
||||
put: function (path, handler) {
|
||||
this.registered['put-' + path] = handler;
|
||||
},
|
||||
delete: function (path, handler) {
|
||||
this.registered['delete-' + path] = handler;
|
||||
},
|
||||
all: function (path, handler) {
|
||||
this.registered['all-' + path] = handler;
|
||||
}
|
||||
};
|
||||
|
||||
describe('requestor', () => {
|
||||
beforeEach(() => {
|
||||
mock.registered = {};
|
||||
});
|
||||
|
||||
it('should detect all requests on root', () => {
|
||||
requestor(mock, './test/root');
|
||||
expect(mock.registered).to.have.all.keys([
|
||||
'post-/',
|
||||
'get-/',
|
||||
'put-/',
|
||||
'delete-/',
|
||||
'all-/'
|
||||
]);
|
||||
});
|
||||
|
||||
it('should detect requests on root.subfolder', () => {
|
||||
requestor(mock, './test/root.sub');
|
||||
expect(mock.registered).to.have.all.keys([
|
||||
'post-/sub/',
|
||||
'get-/sub/',
|
||||
'put-/sub/',
|
||||
'delete-/sub/',
|
||||
'all-/sub/'
|
||||
]);
|
||||
});
|
||||
|
||||
it('should detect requests on subfolder', () => {
|
||||
requestor(mock, './test/sub');
|
||||
expect(mock.registered).to.have.all.keys([
|
||||
'post-/sub/',
|
||||
'get-/sub/',
|
||||
'put-/sub/',
|
||||
'delete-/sub/',
|
||||
'all-/sub/',
|
||||
'get-/sub/lv1/lv2/lv3/',
|
||||
'all-/sub/root/'
|
||||
]);
|
||||
});
|
||||
|
||||
it('should build requests with subdirectory', () => {
|
||||
requestor(mock, './test/sub', { subdir: 'test' });
|
||||
expect(mock.registered).to.have.all.keys([
|
||||
'post-/test/sub/',
|
||||
'get-/test/sub/',
|
||||
'put-/test/sub/',
|
||||
'delete-/test/sub/',
|
||||
'all-/test/sub/',
|
||||
'get-/test/sub/lv1/lv2/lv3/',
|
||||
'all-/test/sub/root/'
|
||||
]);
|
||||
});
|
||||
});
|
||||
const { describe, it, beforeEach: before_each } = require ('mocha');
|
||||
const { expect } = require ('chai');
|
||||
|
||||
const requestor = require ('../index');
|
||||
|
||||
const mock = {
|
||||
registered: {},
|
||||
post (path, handler) {
|
||||
this.registered[`post-${path}`] = handler;
|
||||
},
|
||||
get (path, handler) {
|
||||
this.registered[`get-${path}`] = handler;
|
||||
},
|
||||
put (path, handler) {
|
||||
this.registered[`put-${path}`] = handler;
|
||||
},
|
||||
delete (path, handler) {
|
||||
this.registered[`delete-${path}`] = handler;
|
||||
},
|
||||
all (path, handler) {
|
||||
this.registered[`all-${path}`] = handler;
|
||||
}
|
||||
};
|
||||
|
||||
describe ('requestor', () => {
|
||||
before_each (() => {
|
||||
mock.registered = {};
|
||||
});
|
||||
|
||||
it ('should detect all requests on root', () => {
|
||||
requestor (mock, './test/root');
|
||||
expect (mock.registered).to.have.all.keys ([
|
||||
'post-/',
|
||||
'get-/',
|
||||
'put-/',
|
||||
'delete-/',
|
||||
'all-/'
|
||||
]);
|
||||
});
|
||||
|
||||
it ('should detect requests on root.subfolder', () => {
|
||||
requestor (mock, './test/root.sub');
|
||||
expect (mock.registered).to.have.all.keys ([
|
||||
'post-/sub/',
|
||||
'get-/sub/',
|
||||
'put-/sub/',
|
||||
'delete-/sub/',
|
||||
'all-/sub/'
|
||||
]);
|
||||
});
|
||||
|
||||
it ('should detect requests on subfolder', () => {
|
||||
requestor (mock, './test/sub');
|
||||
expect (mock.registered).to.have.all.keys ([
|
||||
'post-/sub/',
|
||||
'get-/sub/',
|
||||
'put-/sub/',
|
||||
'delete-/sub/',
|
||||
'all-/sub/',
|
||||
'get-/sub/lv1/lv2/lv3/',
|
||||
'all-/sub/root/'
|
||||
]);
|
||||
});
|
||||
|
||||
it ('should build requests with subdirectory', () => {
|
||||
requestor (mock, './test/sub', { subdir: 'test' });
|
||||
expect (mock.registered).to.have.all.keys ([
|
||||
'post-/test/sub/',
|
||||
'get-/test/sub/',
|
||||
'put-/test/sub/',
|
||||
'delete-/test/sub/',
|
||||
'all-/test/sub/',
|
||||
'get-/test/sub/lv1/lv2/lv3/',
|
||||
'all-/test/sub/root/'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -0,0 +1,3 @@
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
module.exports = (req, res, next, opts) => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
module.exports = () => {
|
||||
// dummy endpoint: do nothing
|
||||
};
|
||||
|
Reference in New Issue
Block a user