31 lines
850 B
JavaScript
31 lines
850 B
JavaScript
|
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-/']);
|
||
|
});
|
||
|
});
|