@@ -40,6 +40,7 @@ class ParentView extends BaseParentView {
40
40
< a id ="a-grandchildlink " route ="grandchild " query-name ="test "> </ a >
41
41
< a id ="a-rootlink2 " route ="root " param-id ="2 "> </ a >
42
42
< a id ="a-rootlink3 " route ="root "> </ a >
43
+ < a id ="a-secondrootlink " route ="secondroot " param-person-id ="2 " query-test-value ="yyy "> </ a >
43
44
< a id ="a-replace " route ="parent " replace > </ a >
44
45
< a id ="a-childlink " route ="child " query-name ="test "> </ a >
45
46
< div id ="div-a-parent " route ="parent "> < a id ="childanchor "> </ a > < a id ="childanchor2 "> </ a > < div > < a id ="childanchor3 "> </ a > </ div > </ div >
@@ -101,6 +102,7 @@ describe('routerLinks', () => {
101
102
} )
102
103
} )
103
104
route ( 'root' , { path : 'root/:id' , component : ParentView } )
105
+ route ( 'secondroot' , { path : 'secondroot/:personId' , component : ParentView } )
104
106
}
105
107
parentComponent = ParentView
106
108
router = new Router ( { location : 'memory' , outlet, routes } )
@@ -119,12 +121,29 @@ describe('routerLinks', () => {
119
121
const parentEl = document . querySelector ( parentTag )
120
122
await parentEl . updateComplete
121
123
122
- expect ( $ ( '#a-parentlink' ) . attr ( 'href' ) ) . to . be . equal ( '/parent' )
124
+ expect ( $ ( '#a-parentlink' ) . attr ( 'href' ) ) . to . be . equal ( '/parent' )
125
+ } )
126
+ } )
127
+
128
+ it ( 'should use param-* and query-* attributes to generate href' , async function ( ) {
129
+ return router . transitionTo ( 'parent' ) . then ( async function ( ) {
130
+ const parentEl = document . querySelector ( parentTag )
131
+ await parentEl . updateComplete
132
+
123
133
expect ( $ ( '#a-rootlink2' ) . attr ( 'href' ) ) . to . be . equal ( '/root/2' )
124
134
expect ( $ ( '#a-grandchildlink' ) . attr ( 'href' ) ) . to . be . equal ( '/parent/child/grandchild?name=test' )
125
135
} )
126
136
} )
127
137
138
+ it ( 'should convert param-* and query-* attributes from kebab to camel case' , async function ( ) {
139
+ return router . transitionTo ( 'parent' ) . then ( async function ( ) {
140
+ const parentEl = document . querySelector ( parentTag )
141
+ await parentEl . updateComplete
142
+
143
+ expect ( $ ( '#a-secondrootlink' ) . attr ( 'href' ) ) . to . be . equal ( '/secondroot/2?testValue=yyy' )
144
+ } )
145
+ } )
146
+
128
147
it ( 'should update href attributes in anchor tags when attribute is changed' , function ( ) {
129
148
return router . transitionTo ( 'parent' ) . then ( async function ( ) {
130
149
const parentEl = document . querySelector ( parentTag )
0 commit comments