@@ -14,32 +14,126 @@ describe('Connected Next Router', () => {
14
14
cy . visit ( '/' ) ;
15
15
} ) ;
16
16
17
- it ( 'Push route with Redux action' , ( ) => {
17
+ it ( 'Push route (with query) with Redux action' , ( ) => {
18
18
cy . contains ( 'Push /about with Redux action' ) . click ( ) ;
19
- cy . location ( 'pathname' ) . should ( 'include' , '/about' ) ;
19
+ cy . location ( 'pathname' ) . should ( 'equal' , '/about' ) ;
20
+ cy . location ( 'search' ) . should ( 'equal' , '?foo=bar' )
21
+ cy . window ( )
22
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
23
+ . should ( 'deep.equal' , {
24
+ location : {
25
+ href : '/about?foo=bar' ,
26
+ pathname : '/about' ,
27
+ search : '?foo=bar' ,
28
+ hash : ''
29
+ }
30
+ } ) ;
31
+ } ) ;
32
+
33
+ it ( 'Push route (with hash) with Redux action' , ( ) => {
34
+ cy . contains ( 'Push /#foo with Redux action' ) . click ( ) ;
35
+ cy . location ( 'pathname' ) . should ( 'equal' , '/' ) ;
36
+ cy . location ( 'hash' ) . should ( 'equal' , '#foo' )
37
+ cy . window ( )
38
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
39
+ . should ( 'deep.equal' , {
40
+ location : {
41
+ href : '/#foo' ,
42
+ pathname : '/' ,
43
+ search : '' ,
44
+ hash : '#foo'
45
+ }
46
+ } ) ;
20
47
} ) ;
21
48
22
49
it ( 'Replace route with Redux action' , ( ) => {
23
50
cy . contains ( 'Replace /blog/2 with Redux action' ) . click ( ) ;
24
- cy . location ( 'pathname' ) . should ( 'include' , '/blog/2' ) ;
51
+ cy . location ( 'pathname' ) . should ( 'equal' , '/blog/2' ) ;
52
+ cy . window ( )
53
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
54
+ . should ( 'deep.equal' , {
55
+ location : {
56
+ href : '/blog/2' ,
57
+ pathname : '/blog/2' ,
58
+ search : '' ,
59
+ hash : ''
60
+ }
61
+ } ) ;
62
+
25
63
cy . contains ( 'Replace / with Redux action' ) . click ( ) ;
26
64
cy . location ( 'pathname' ) . should ( 'equal' , '/' ) ;
65
+ cy . window ( )
66
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
67
+ . should ( 'deep.equal' , {
68
+ location : {
69
+ href : '/' ,
70
+ pathname : '/' ,
71
+ search : '' ,
72
+ hash : ''
73
+ }
74
+ } ) ;
27
75
} ) ;
28
76
29
77
it ( 'Go back with Redux action' , ( ) => {
30
78
cy . contains ( 'Push /about with Redux action' ) . click ( ) ;
31
- cy . location ( 'pathname' ) . should ( 'include' , '/about' ) ;
79
+ cy . location ( 'pathname' ) . should ( 'equal' , '/about' ) ;
80
+ cy . location ( 'search' ) . should ( 'equal' , '?foo=bar' )
81
+ cy . window ( )
82
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
83
+ . should ( 'deep.equal' , {
84
+ location : {
85
+ href : '/about?foo=bar' ,
86
+ pathname : '/about' ,
87
+ search : '?foo=bar' ,
88
+ hash : ''
89
+ }
90
+ } ) ;
91
+
32
92
cy . contains ( 'Go Back with Redux action' ) . click ( ) ;
33
93
cy . location ( 'pathname' ) . should ( 'equal' , '/' ) ;
94
+ cy . window ( )
95
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
96
+ . should ( 'deep.equal' , {
97
+ location : {
98
+ href : '/' ,
99
+ pathname : '/' ,
100
+ search : '' ,
101
+ hash : ''
102
+ }
103
+ } ) ;
34
104
} ) ;
35
105
36
106
it ( 'Go forward with Redux action' , ( ) => {
37
107
cy . contains ( 'Push /about with Redux action' ) . click ( ) ;
38
- cy . location ( 'pathname' ) . should ( 'include' , '/about' ) ;
108
+ cy . location ( 'pathname' ) . should ( 'equal' , '/about' ) ;
109
+ cy . location ( 'search' ) . should ( 'equal' , '?foo=bar' )
110
+ cy . window ( )
111
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
112
+ . should ( 'deep.equal' , {
113
+ location : {
114
+ href : '/about?foo=bar' ,
115
+ pathname : '/about' ,
116
+ search : '?foo=bar' ,
117
+ hash : ''
118
+ }
119
+ } ) ;
120
+
39
121
cy . go ( 'back' ) ;
40
122
cy . location ( 'pathname' ) . should ( 'equal' , '/' ) ;
123
+
41
124
cy . contains ( 'Go Forward with Redux action' ) . click ( ) ;
42
- cy . location ( 'pathname' ) . should ( 'include' , '/about' ) ;
125
+ cy . location ( 'pathname' ) . should ( 'equals' , '/about' ) ;
126
+ cy . location ( 'search' ) . should ( 'equal' , '?foo=bar' )
127
+ cy . window ( )
128
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
129
+ . should ( 'deep.equal' , {
130
+ location : {
131
+ href : '/about?foo=bar' ,
132
+ pathname : '/about' ,
133
+ search : '?foo=bar' ,
134
+ hash : ''
135
+ }
136
+ } ) ;
43
137
} ) ;
44
138
45
139
it ( 'Prefetch with Redux action' , ( ) => {
@@ -52,9 +146,18 @@ describe('Connected Next Router', () => {
52
146
} ) ;
53
147
54
148
it ( 'Ignores invalid URLs passed to the action' , ( ) => {
55
- cy . visit ( '/' ) ;
56
149
cy . contains ( 'Push empty url' ) . click ( ) ;
57
150
cy . location ( 'pathname' ) . should ( 'equal' , '/' ) ;
151
+ cy . window ( )
152
+ . then ( ( window ) => window . reduxStore . getState ( ) . router )
153
+ . should ( 'deep.equal' , {
154
+ location : {
155
+ href : '/' ,
156
+ pathname : '/' ,
157
+ search : '' ,
158
+ hash : ''
159
+ }
160
+ } ) ;
58
161
} ) ;
59
162
} ) ;
60
163
0 commit comments