/**
 * This file is part of the Koater lib.
 *
 * (c) Irwin Lourtet <dev@lourtet.fr>
 *
 * For the full copyright and license information, please view
 * the LICENSE file distributed with this source code.
 *
 * @author Irwin Lourtet <dev@lourtet.fr>
 */

let test = require('unit.js');
let router = require('../../src');

describe('Router ', function() {
  it('should add route without name', function() {
    let route;
    let fn = function(){};
    let path = '/my-path';
    let method = 'GET';
    router.use({method, path, fn});

    test.number(Object.keys(router._routes).length).is(1);
    test.bool(router._routes.hasOwnProperty(method + '_' + path)).isTrue();

    route = router._routes[method + '_' + path];
    test.string(route.method).is(method);
    test.string(route.path).is(path);
    test.string(route.name).is(method + '_' + path);
    test.function(route.fn).is(fn);
  });

  it('should add route with name', function() {
    let route;
    let fn = function(){};
    let path = '/my-path2';
    let method = 'POST';
    let name = 'myRouteName';
    router.use({method, path, fn, name});

    test.number(Object.keys(router._routes).length).is(2);
    test.bool(router._routes.hasOwnProperty(method + '_' + path)).isTrue();

    route = router._routes[method + '_' + path];
    test.string(route.method).is(method);
    test.string(route.path).is(path);
    test.string(route.name).is(name);
    test.function(route.fn).is(fn);
  })
});

@@ -349,16 +349,50 @@
 ion() %7B%0A
+  let routeName = 'myRouteName';%0A%0A
   it('sh
@@ -1072,38 +1072,8 @@
 T';%0A
-    let name = 'myRouteName';%0A
     
@@ -1106,16 +1106,27 @@
 fn, name
+: routeName
 %7D);%0A%0A   
@@ -1418,17 +1418,22 @@
 ame).is(
-n
+routeN
 ame);%0A  
@@ -1462,21 +1462,192 @@
 fn).is(fn);%0A
+  %7D);%0A%0A  it('should retrieve route by its name', function() %7B%0A    let route = router.getByName(routeName);%0A%0A    test.object(route).match((obj) =%3E obj.name === routeName);%0A
   %7D)%0A%7D);%0A

Add test for getByName