From 72ac68b98eefae66194d71005a0d822d32632431 Mon Sep 17 00:00:00 2001 From: mattbrooks2010 Date: Wed, 4 Dec 2013 13:50:18 +0000 Subject: [PATCH] Added missing tests. - Added routie-tests.ts file - Tweaked definition file for compilation using tsc --noImplicitAny --- routie/routie-tests.ts | 57 ++++++++++++++++++++++++++++++++++++++++++ routie/routie.d.ts | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 routie/routie-tests.ts diff --git a/routie/routie-tests.ts b/routie/routie-tests.ts new file mode 100644 index 0000000000..aaf0756750 --- /dev/null +++ b/routie/routie-tests.ts @@ -0,0 +1,57 @@ +/// + +// BASIC + +// There are three ways to call routie. Here is the most basic way: + +routie("users", function () { + // This gets called when hash == #users +}); + +// If you want to define multiple routes you can pass in an object like this: + +routie({ + "users": function () { + }, + "about": function () { + } +}); + +// If you want to trigger a route manually, you can call routie like this: + +routie("users/bob"); // window.location.hash will be #users/bob + +// ADVANCED + +// Routie also supports regex style routes, so you can do advanced routing like this: + +routie("users/:name", function (name) { + // name == "bob"; +}); + +routie("users/bob"); + +// Optional params: + +routie("users/?:name", function (name) { + //name == undefined + //then + //name == bob +}); + +routie("users/"); +routie("users/bob"); + +// Wildcard: + +routie("users/*", function () { +}); + +routie("users/12312312"); + +// Catch all: + +routie("*", function () { +}); + +routie("anything"); \ No newline at end of file diff --git a/routie/routie.d.ts b/routie/routie.d.ts index 9129043a8a..9317904d4c 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped interface Route { - constructor(path: string, name: string); + constructor(path: string, name: string): Route; addHandler(fn: Function): void; removeHandler(fn: Function): void; run(params: any): void;