@@ -955,6 +955,41 @@ describe('transition', function() {
955
955
router . urlService . url ( '/urlRedirect' ) ;
956
956
} ) ;
957
957
958
+ it ( 'should replace the current url when redirecting a url sync transition, even if the redirect is ignored' , async done => {
959
+ router . stateRegistry . register ( {
960
+ name : 'queryparam' ,
961
+ url : '/?param' ,
962
+ } ) ;
963
+
964
+ await router . stateService . go ( 'queryparam' , { param : undefined } ) ;
965
+ expect ( router . globals . params . param ) . toEqual ( undefined ) ;
966
+
967
+ router . transitionService . onStart ( { } , trans => {
968
+ // redirect transition removing ?param=foo
969
+ if ( trans . params ( ) . param === 'foo' ) {
970
+ return trans . targetState ( ) . withParams ( { param : undefined } ) ;
971
+ }
972
+ } ) ;
973
+
974
+ router . urlService . url ( '/?param=foo' ) ;
975
+ const url = spyOn ( router . locationService , 'url' ) . and . callThrough ( ) ;
976
+ const update = spyOn ( router . urlRouter , 'update' ) . and . callThrough ( ) ;
977
+
978
+ router . transitionService . onError ( { } , trans => {
979
+ if ( trans . error ( ) . type === RejectType . IGNORED ) {
980
+ setTimeout ( ( ) => {
981
+ expect ( update . calls . count ( ) ) . toBe ( 1 ) ;
982
+ expect ( url . calls . count ( ) ) . toBe ( 2 ) ;
983
+ expect ( url . calls . argsFor ( 0 ) ) . toEqual ( [ ] ) ;
984
+ expect ( url . calls . argsFor ( 1 ) ) . toEqual ( [ '/' , true ] ) ;
985
+ expect ( router . urlService . url ( ) ) . toBe ( '/' ) ;
986
+ expect ( router . globals . params . param ) . toEqual ( undefined ) ;
987
+ done ( ) ;
988
+ } ) ;
989
+ }
990
+ } ) ;
991
+ } ) ;
992
+
958
993
it ( 'should not replace the current url when redirecting a url sync with { location: false }' , done => {
959
994
router . transitionService . onBefore ( { to : 'requiresAuth' } , trans => {
960
995
return router . stateService . target ( 'redirectTarget' , null , { location : false } ) ;
0 commit comments