create-route-mock.spec.js 921 B

12345678910111213141516171819202122232425262728
  1. import {expect} from 'chai';
  2. import {HttpMethod, Route} from '../route.js';
  3. import {createRouteMock} from './create-route-mock.js';
  4. describe('createRouteMock', function () {
  5. it('returns an instance of Route with default options', function () {
  6. const res = createRouteMock();
  7. expect(res).to.be.instanceof(Route);
  8. expect(res.method).to.be.eq(HttpMethod.GET);
  9. expect(res.path).to.be.eq('/');
  10. expect(res.handler()).to.be.eq('OK');
  11. });
  12. it('sets the "method" option', function () {
  13. const res = createRouteMock({method: HttpMethod.POST});
  14. expect(res.method).to.be.eq(HttpMethod.POST);
  15. });
  16. it('sets the "path" option', function () {
  17. const res = createRouteMock({path: 'test'});
  18. expect(res.path).to.be.eq('test');
  19. });
  20. it('sets the "handler" option', function () {
  21. const res = createRouteMock({handler: () => 'Hey!'});
  22. expect(res.handler()).to.be.eq('Hey!');
  23. });
  24. });