@@ -129,17 +129,18 @@ describe('react-router-component (on server)', function() {
129129 var Level2 = React . createClass ( {
130130
131131 render : function ( ) {
132+ var thisSlug = this . props . slug ;
132133 return Router . Locations ( { className : 'L2' , contextual : true } ,
133134 Router . Location ( {
134135 path : '/' ,
135136 handler : function ( props ) {
136- return Router . Link ( { href : '/hello' } ) ;
137+ return Router . Link ( { href : '/hello' , 'data-slug' : thisSlug } ) ;
137138 }
138139 } ) ,
139140 Router . Location ( {
140141 path : '/:slug' ,
141142 handler : function ( props ) {
142- return Router . Link ( { global : true , href : '/hi' } ) ;
143+ return Router . Link ( { global : true , href : '/hi' , 'data-slug' : props . slug } ) ;
143144 }
144145 } )
145146 )
@@ -149,11 +150,12 @@ describe('react-router-component (on server)', function() {
149150 var Level1 = React . createClass ( {
150151
151152 render : function ( ) {
153+ var thisSlug = this . props . slug ;
152154 return Router . Locations ( { className : 'L1' , contextual : true } ,
153155 Router . Location ( {
154156 path : '/' ,
155157 handler : function ( props ) {
156- return Router . Link ( { href : '/l2' } ) ;
158+ return Router . Link ( { href : '/l2' , 'data-slug' : thisSlug } ) ;
157159 }
158160 } ) ,
159161 Router . Location ( {
@@ -180,22 +182,33 @@ describe('react-router-component (on server)', function() {
180182 var markup = React . renderComponentToString ( App ( { path : '/l1/nice' } ) ) ;
181183 assert ( markup . match ( / c l a s s = " A p p " / ) ) ;
182184 assert ( markup . match ( / c l a s s = " L 1 " / ) ) ;
183- assert ( markup . match ( / h r e f = " & # x 2 f ; l 1 & # x 2 f ; n i c e & # x 2 f ; l 2 " / ) ) ;
185+ assert ( markup . match ( / h r e f = " \/ l 1 \/ n i c e \/ l 2 " / ) ) ;
186+ assert ( markup . match ( / d a t a - s l u g = " n i c e " / ) ) ;
187+ } ) ;
188+
189+ it ( 'renders Link component with href scoped to its prefix - trailing slash' , function ( ) {
190+ var markup = React . renderComponentToString ( App ( { path : '/l1/nice/' } ) ) ;
191+ assert ( markup . match ( / c l a s s = " A p p " / ) ) ;
192+ assert ( markup . match ( / c l a s s = " L 1 " / ) ) ;
193+ assert ( markup . match ( / h r e f = " \/ l 1 \/ n i c e \/ l 2 " / ) ) ;
194+ assert ( markup . match ( / d a t a - s l u g = " n i c e " / ) ) ;
184195 } ) ;
185196
186197 it ( 'renders nested Link component with href scoped to its prefix' , function ( ) {
187198 var markup = React . renderComponentToString ( App ( { path : '/l1/nice/l2' } ) ) ;
188199 assert ( markup . match ( / c l a s s = " A p p " / ) ) ;
189200 assert ( markup . match ( / c l a s s = " L 1 " / ) ) ;
190201 assert ( markup . match ( / c l a s s = " L 2 " / ) ) ;
191- assert ( markup . match ( / h r e f = " & # x 2 f ; l 1 & # x 2 f ; n i c e & # x 2 f ; l 2 & # x 2 f ; h e l l o " / ) ) ;
202+ assert ( markup . match ( / h r e f = " \/ l 1 \/ n i c e \/ l 2 \/ h e l l o " / ) ) ;
203+ assert ( markup . match ( / d a t a - s l u g = " l 2 " / ) ) ;
192204 } ) ;
193205
194206 it ( 'renders global Link component with correct href (not scoped to a router)' , function ( ) {
195207 var markup = React . renderComponentToString ( App ( { path : '/l1/nice/l2/foo' } ) ) ;
196208 assert ( markup . match ( / c l a s s = " A p p " / ) ) ;
197209 assert ( markup . match ( / c l a s s = " L 2 " / ) ) ;
198- assert ( markup . match ( / h r e f = " & # x 2 f ; h i " / ) ) ;
210+ assert ( markup . match ( / h r e f = " \/ h i " / ) ) ;
211+ assert ( markup . match ( / d a t a - s l u g = " f o o " / ) ) ;
199212 } ) ;
200213
201214 } ) ;
0 commit comments