{"size": 1477, "ext": "js", "max_stars_repo_path": "test/tests/01_test_register.js", "max_stars_repo_name": "kisiwu/novice-routing", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/tests/01_test_register.js", "max_issues_repo_name": "kisiwu/novice-routing", "max_issues_repo_issues_event_min_datetime": "2020-07-20T10:39:52.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-01T08:52:49.000Z", "max_forks_repo_path": "test/tests/01_test_register.js", "max_forks_repo_name": "kisiwu/novice-routing", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 27.8679245283, "max_line_length": 78, "alphanum_fraction": 0.6032498307}
const router = require('../../index')();

describe("Define routes and meta", () => {

  router.all('/*', function allMiddleware (req, res, next) {
    next()
  });
  // define the about route
  router.get({
    path: '/about',
    name: 'about',
    tags: ['About']
  }, function aboutToDo(req, res) {
    res.json(req.meta)
  });
  // define the post route
  router.post({
    path: '/post',
    name: 'Post',
    description: 'Post a comment',
    tags: 'Comments'
  }, function postToDo(req, res) {
    res.json(req.meta)
  });

  it("should have registered 'all' route", function() {
    expect(router.stack[0].route.path).to.equal('/*');
  });

  it("should have registered 'get' route", function() {
    expect(router.stack[1].route.path).to.equal('/about');
  });

  it("should have registered 'post' route", function() {
    expect(router.stack[2].route.path).to.equal('/post');
  });

  it("should have registered 'get' meta", function() {
    expect(router.stack[1].route.meta.name).to.equal('about');
    expect(router.stack[1].route.meta.tags)
      .to.be.an('array', 'meta.tags in not an array')
      .to.eql(['About']);
  });

  it("should have registered 'post' meta", function() {
    expect(router.stack[2].route.meta.name).to.equal('Post');
    expect(router.stack[2].route.meta.description).to.equal('Post a comment');
    expect(router.stack[2].route.meta.tags)
      .to.be.an('array', 'meta.tags in not an array')
      .to.eql(['Comments']);
  });
});
