mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-11 12:40:15 +00:00
Merge pull request #1374 from mattbrooks2010/master
Added missing tests.
This commit is contained in:
57
routie/routie-tests.ts
Normal file
57
routie/routie-tests.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
/// <reference path="routie.d.ts" />
|
||||
|
||||
// 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");
|
||||
2
routie/routie.d.ts
vendored
2
routie/routie.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user