diff --git a/index.js b/index.js index fc99c1d..5bc45e9 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,9 @@ function createRoute(route) { (acc, [key, value]) => acc.replace(new RegExp(`:${key}`, "g"), value), route ); - routeFn.getType = route; + + routeFn.getType = () => route; + routeFn.toString = () => route; return routeFn; } diff --git a/index.test.js b/index.test.js index fb50e1a..ebbe0c1 100644 --- a/index.test.js +++ b/index.test.js @@ -37,8 +37,12 @@ test("to return nested route, e.g. people/:id/tasks/:taskId", t => { ); }); -test("to set computed property (set getType)", t => { +test("to set getType property", t => { const routes = createRoutes({ tasks: "/tasks/:id" }); + t.is("/tasks/:id", routes.tasksPath.getType()); +}); - t.is("/tasks/:id", routes.tasksPath.getType); +test("to set toString property", t => { + const routes = createRoutes({ tasks: "/tasks/:id" }); + t.is("/tasks/:id", routes.tasksPath.toString()); });