@@ -110,8 +110,14 @@ describe('utils/router', () => {
110110
111111 it ( 'parses nothing to default' , async ( ) => {
112112 expect ( computeHref ( ) ) . toEqual ( '#' )
113- expect ( computeHref ( undefined , '/' , '' ) ) . toEqual ( '/' )
114- expect ( computeHref ( undefined , '' , '' ) ) . toEqual ( '' )
113+ expect ( computeHref ( undefined , undefined , '/' , '' ) ) . toEqual ( '/' )
114+ expect ( computeHref ( undefined , undefined , '' , '' ) ) . toEqual ( '' )
115+ } )
116+
117+ it ( 'returns null when tag is not `a`' , async ( ) => {
118+ expect ( computeHref ( { } , 'div' ) ) . toEqual ( null )
119+ expect ( computeHref ( undefined , 'div' , '/' , '' ) ) . toEqual ( null )
120+ expect ( computeHref ( undefined , 'span' , '' , '/' ) ) . toEqual ( null )
115121 } )
116122
117123 it ( 'returns href when both href and to provided' , async ( ) => {
@@ -124,8 +130,8 @@ describe('utils/router', () => {
124130
125131 it ( 'parses empty `href` to default' , async ( ) => {
126132 expect ( computeHref ( { href : '' } ) ) . toEqual ( '#' )
127- expect ( computeHref ( { href : '' } , '/' , '' ) ) . toEqual ( '/' )
128- expect ( computeHref ( { href : '' } , '' , '' ) ) . toEqual ( '' )
133+ expect ( computeHref ( { href : '' } , 'a' , ' /', '' ) ) . toEqual ( '/' )
134+ expect ( computeHref ( { href : '' } , 'a' , ' ', '' ) ) . toEqual ( '' )
129135 } )
130136
131137 it ( 'parses `to` when string' , async ( ) => {
@@ -173,8 +179,8 @@ describe('utils/router', () => {
173179
174180 it ( 'parses empty `to` to fallback default' , async ( ) => {
175181 expect ( computeHref ( { to : { } } ) ) . toEqual ( '#' )
176- expect ( computeHref ( { to : { } } , '#' , '' ) ) . toEqual ( '#' )
177- expect ( computeHref ( { to : { } } , '/' , '#' ) ) . toEqual ( '/' )
182+ expect ( computeHref ( { to : { } } , 'a' , ' #', '' ) ) . toEqual ( '#' )
183+ expect ( computeHref ( { to : { } } , 'a' , ' /', '#' ) ) . toEqual ( '/' )
178184 } )
179185
180186 it ( 'parses complete `to`' , async ( ) => {
0 commit comments