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 with alerts' : 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 ) return
11
+
12
+ browser
14
13
. click ( 'li:nth-child(2) a' )
15
14
. dismissAlert ( )
16
15
. waitFor ( 100 )
@@ -63,16 +62,8 @@ module.exports = {
63
62
. assert . urlEquals ( 'http://localhost:8080/navigation-guards/foo' )
64
63
. assert . containsText ( '.view' , 'foo' )
65
64
66
- . click ( 'li:nth-child(4) a' )
67
- . assert . urlEquals ( 'http://localhost:8080/navigation-guards/baz' )
68
- . assert . containsText ( '.view' , 'baz (not saved)' )
69
- . click ( 'button' )
70
- . assert . containsText ( '.view' , 'baz (saved)' )
71
- . click ( 'li:nth-child(1) a' )
72
- . assert . urlEquals ( 'http://localhost:8080/navigation-guards/' )
73
- . assert . containsText ( '.view' , 'home' )
74
-
75
- // test initial visit
65
+ // test initial visit
66
+ browser
76
67
. url ( 'http://localhost:8080/navigation-guards/foo' )
77
68
. dismissAlert ( )
78
69
. waitFor ( 100 )
@@ -100,16 +91,32 @@ module.exports = {
100
91
. acceptAlert ( )
101
92
. assert . urlEquals ( 'http://localhost:8080/navigation-guards/bar' )
102
93
. assert . containsText ( '.view' , 'bar' )
94
+ } ,
95
+ 'navigation guards' : function ( browser ) {
96
+ browser
97
+ // back to home
98
+ . url ( 'http://localhost:8080/navigation-guards/' )
99
+ . waitForElementVisible ( '#app' , 1000 )
100
+ . assert . containsText ( '.view' , 'home' )
103
101
104
- // in-component guard
102
+ . click ( 'li:nth-child(4) a' )
103
+ . assert . urlEquals ( 'http://localhost:8080/navigation-guards/baz' )
104
+ . assert . containsText ( '.view' , 'baz (not saved)' )
105
+ . click ( 'button' )
106
+ . assert . containsText ( '.view' , 'baz (saved)' )
107
+ . click ( 'li:nth-child(1) a' )
108
+ . assert . urlEquals ( 'http://localhost:8080/navigation-guards/' )
109
+ . assert . containsText ( '.view' , 'home' )
110
+
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