@@ -608,6 +608,38 @@ describe('state', function () {
608
608
$rootScope . $apply ( ) ;
609
609
expect ( $state . current . name ) . toBe ( '' ) ;
610
610
} ) ) ;
611
+
612
+ it ( 'should replace browser history when "replace" enabled' , inject ( function ( $state , $rootScope , $location , $q ) {
613
+ var originalReplaceFn = $location . replace , replaceWasCalled = false ;
614
+
615
+ // @todo Replace this with a spy
616
+ var decoratedReplaceFn = function ( ) {
617
+ replaceWasCalled = true ;
618
+ originalReplaceFn . call ( $location ) ;
619
+ } ;
620
+ $location . replace = decoratedReplaceFn ;
621
+
622
+ $state . transitionTo ( 'about' , { } , { location : 'replace' } ) ;
623
+ $q . flush ( ) ;
624
+
625
+ expect ( replaceWasCalled ) . toEqual ( true ) ;
626
+ } ) ) ;
627
+
628
+ it ( 'should not replace history normally' , inject ( function ( $state , $rootScope , $location , $q ) {
629
+ var originalReplaceFn = $location . replace , replaceWasCalled = false ;
630
+
631
+ // @todo Replace with spy
632
+ var decoratedReplaceFn = function ( ) {
633
+ replaceWasCalled = true ;
634
+ originalReplaceFn . call ( $location ) ;
635
+ } ;
636
+ $location . replace = decoratedReplaceFn ;
637
+
638
+ $state . transitionTo ( 'about' ) ;
639
+ $q . flush ( ) ;
640
+
641
+ expect ( replaceWasCalled ) . toEqual ( false ) ;
642
+ } ) ) ;
611
643
} ) ;
612
644
613
645
describe ( 'default properties' , function ( ) {
0 commit comments