1
- describe ( "jsRoute" , function ( ) {
2
-
3
- beforeEach ( function ( ) {
4
-
5
- } ) ;
6
-
7
- it ( "should be able to add routes" , function ( ) {
8
- route . add ( '^$' , function ( ) { self . x = self . x + 1 ; } ) ;
9
- expect ( route . routes . indexOf ( "^$" ) > - 1 ) . toBeTruthy ( ) ;
10
- } ) ;
11
-
12
- it ( "should be able to init routing" , function ( ) {
13
- location . hash = "#22-10-2012" ;
14
-
15
- route . add ( '^\\d{1,2}\\-\\d{1,2}\-\\d{4}$' , function ( x ) {
16
- if ( x === '22-10-2012' ) {
17
- location . hash = '#alterado' ;
18
- }
19
- } ) ;
20
-
21
- runs ( function ( ) {
22
- route . init ( ) ;
23
- } ) ;
24
-
25
- waits ( 1000 ) ;
26
-
27
- runs ( function ( ) {
28
- expect ( location . hash ) . toEqual ( '#alterado' ) ;
29
- } ) ;
30
-
31
- } ) ;
32
-
33
- it ( "should be able to force a route" , function ( ) {
34
- route . add ( '^\\d{1,2}\\-\\d{1,2}\-\\d{4}$' , function ( x ) {
35
- if ( x === '23-10-2012' ) {
36
- location . hash = '#alterado' ;
37
- }
38
- } ) ;
39
-
40
- runs ( function ( ) {
41
- route . call ( '#23-10-2012' ) ;
42
- } ) ;
43
-
44
- waits ( 1000 ) ;
45
-
46
- runs ( function ( ) {
47
- expect ( location . hash ) . toEqual ( '#alterado' ) ;
48
- } ) ;
49
-
50
- } ) ;
51
- } ) ;
1
+ /*global describe, afterEach, beforeEach, it, expect, runs, waits, window, route*/
2
+
3
+ ( function ( window , route ) {
4
+
5
+ 'use strict' ;
6
+
7
+ describe ( "jsRoute" , function ( ) {
8
+
9
+ var self = this ;
10
+
11
+ beforeEach ( function ( ) {
12
+ route . routes = [ ] ;
13
+ route . funcs = [ ] ;
14
+ self . hash = false ;
15
+ window . clearInterval ( route . interval ) ;
16
+ } ) ;
17
+
18
+ it ( "should be able to add routes" , function ( ) {
19
+ route . add ( '^$' , function ( ) {
20
+ self . x = self . x + 1 ;
21
+ } ) ;
22
+ expect ( route . routes . indexOf ( "^$" ) > - 1 ) . toBeTruthy ( ) ;
23
+ } ) ;
24
+
25
+ it ( "should be able to init routing" , function ( ) {
26
+ window . location . hash = "#22-10-2012" ;
27
+
28
+ route . add ( '^\\d{1,2}-\\d{1,2}-\\d{4}$' , function ( day ) {
29
+ self . hash = day ;
30
+ } ) ;
31
+
32
+ route . init ( ) ;
33
+
34
+ waits ( 1000 ) ;
35
+
36
+ runs ( function ( ) {
37
+ expect ( '22-10-2012' ) . toEqual ( self . hash ) ;
38
+ } ) ;
39
+ } ) ;
40
+
41
+ it ( "should be able to force a route" , function ( ) {
42
+ route . add ( '^\\d{1,2}-\\d{1,2}-\\d{4}$' , function ( day ) {
43
+ self . hash = day ;
44
+ } ) ;
45
+
46
+ route . call ( '23-10-2012' ) ;
47
+ expect ( '23-10-2012' ) . toEqual ( self . hash ) ;
48
+ } ) ;
49
+
50
+ it ( "should be able to use pure regexp as route" , function ( ) {
51
+ route . add ( / ^ \d { 1 , 2 } - \d { 1 , 2 } - \d { 4 } $ / , function ( day ) {
52
+ self . hash = day ;
53
+ } ) ;
54
+
55
+ route . call ( '24-08-2012' ) ;
56
+ expect ( '24-08-2012' ) . toEqual ( self . hash ) ;
57
+ } ) ;
58
+ } ) ;
59
+ } ( window , route ) ) ;
0 commit comments