File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -369,6 +369,7 @@ async function factory(
369369 options : { } as Partial < RouterOptions > ,
370370 resolve : jest . fn ( ) ,
371371 push : jest . fn ( ) . mockResolvedValue ( resolvedLocation ) ,
372+ replace : jest . fn ( ) . mockResolvedValue ( resolvedLocation ) ,
372373 }
373374 router . resolve . mockReturnValueOnce ( resolvedLocation )
374375
@@ -799,6 +800,16 @@ describe('RouterLink', () => {
799800 expect ( router . push ) . toHaveBeenCalledTimes ( 1 )
800801 } )
801802
803+ it ( 'calls router.replace when clicked with replace prop' , async ( ) => {
804+ const { router, wrapper } = await factory (
805+ START_LOCATION_NORMALIZED ,
806+ { to : locations . basic . string , replace : true } ,
807+ locations . basic . normalized
808+ )
809+ wrapper . find ( 'a' ) ! . trigger ( 'click' )
810+ expect ( router . replace ) . toHaveBeenCalledTimes ( 1 )
811+ } )
812+
802813 it ( 'calls router.push with the correct location for aliases' , async ( ) => {
803814 const { router, wrapper } = await factory (
804815 START_LOCATION_NORMALIZED ,
Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ export const RouterLinkImpl = /*#__PURE__*/ defineComponent({
132132 type : [ String , Object ] as PropType < RouteLocationRaw > ,
133133 required : true ,
134134 } ,
135+ replace : Boolean ,
135136 activeClass : String ,
136137 // inactiveClass: String,
137138 exactActiveClass : String ,
You can’t perform that action at this time.
0 commit comments