basic tests, initialize readme

This commit is contained in:
Timo Hocker
2019-12-11 09:32:40 +01:00
parent 6143e972e1
commit 55f631de02
9 changed files with 59 additions and 11 deletions

30
test/main.js Normal file
View File

@@ -0,0 +1,30 @@
const {describe, it} = 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', () => {
it('should detect all requests on root', () => {
requestor(mock, './test/onroot', {});
expect(mock.registered).to.have.all.keys(['post-/', 'get-/', 'put-/', 'delete-/', 'all-/']);
});
});

3
test/onroot/all-root.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};

View File

@@ -0,0 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};

3
test/onroot/get-root.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};

3
test/onroot/not-root.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};

3
test/onroot/post-root.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};

3
test/onroot/put-root.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};