1
1
module . exports = {
2
- 'navigation guards' : function ( browser ) {
3
- // alert commands not available in phantom
4
- if ( process . env . PHANTOMJS ) {
5
- return
6
- }
7
-
2
+ 'navigation guards step one' : function ( browser ) {
8
3
browser
9
4
. url ( 'http://localhost:8080/navigation-guards/' )
10
5
. waitForElementVisible ( '#app' , 1000 )
11
6
. assert . count ( 'li a' , 8 )
12
7
. assert . containsText ( '.view' , 'home' )
13
8
9
+ // alert commands not available in phantom
10
+ if ( process . env . PHANTOMJS ) {
11
+ return
12
+ }
13
+
14
+ browser
14
15
. click ( 'li:nth-child(2) a' )
15
16
. dismissAlert ( )
16
17
. waitFor ( 100 )
@@ -100,16 +101,22 @@ module.exports = {
100
101
. acceptAlert ( )
101
102
. assert . urlEquals ( 'http://localhost:8080/navigation-guards/bar' )
102
103
. assert . containsText ( '.view' , 'bar' )
104
+ } ,
105
+ 'navigation guards step two' : function ( browser ) {
106
+ browser
107
+ // back to home
108
+ . url ( 'http://localhost:8080/navigation-guards/' )
109
+ . assert . containsText ( '.view' , 'home' )
103
110
104
- // in-component guard
111
+ // in-component guard
105
112
. click ( 'li:nth-child(5) a' )
106
- . assert . urlEquals ( 'http://localhost:8080/navigation-guards/bar ' )
107
- . assert . containsText ( '.view' , 'bar ' )
113
+ . assert . urlEquals ( 'http://localhost:8080/navigation-guards/' )
114
+ . assert . containsText ( '.view' , 'home ' )
108
115
. waitFor ( 300 )
109
116
. assert . urlEquals ( 'http://localhost:8080/navigation-guards/qux' )
110
117
. assert . containsText ( '.view' , 'Qux' )
111
118
112
- // async component + in-component guard
119
+ // async component + in-component guard
113
120
. click ( 'li:nth-child(1) a' )
114
121
. assert . urlEquals ( 'http://localhost:8080/navigation-guards/' )
115
122
. assert . containsText ( '.view' , 'home' )
@@ -120,7 +127,7 @@ module.exports = {
120
127
. assert . urlEquals ( 'http://localhost:8080/navigation-guards/qux-async' )
121
128
. assert . containsText ( '.view' , 'Qux' )
122
129
123
- // beforeRouteUpdate
130
+ // beforeRouteUpdate
124
131
. click ( 'li:nth-child(7) a' )
125
132
. assert . urlEquals ( 'http://localhost:8080/navigation-guards/quux/1' )
126
133
. assert . containsText ( '.view' , 'id:1 prevId:0' )
0 commit comments