@@ -833,35 +833,24 @@ describe('state', function () {
833
833
} ) ) ;
834
834
835
835
it ( 'should replace browser history when "replace" enabled' , inject ( function ( $state , $rootScope , $location , $q ) {
836
- var originalReplaceFn = $location . replace , replaceWasCalled = false ;
837
836
838
- // @todo Replace this with a spy
839
- var decoratedReplaceFn = function ( ) {
840
- replaceWasCalled = true ;
841
- originalReplaceFn . call ( $location ) ;
842
- } ;
843
- $location . replace = decoratedReplaceFn ;
837
+ spyOn ( $location , 'replace' ) ;
844
838
845
839
$state . transitionTo ( 'about' , { } , { location : 'replace' } ) ;
846
840
$q . flush ( ) ;
847
841
848
- expect ( replaceWasCalled ) . toEqual ( true ) ;
842
+ expect ( $location . replace ) . toHaveBeenCalled ( ) ;
849
843
} ) ) ;
850
844
851
845
it ( 'should not replace history normally' , inject ( function ( $state , $rootScope , $location , $q ) {
852
- var originalReplaceFn = $location . replace , replaceWasCalled = false ;
853
846
854
- // @todo Replace with spy
855
- var decoratedReplaceFn = function ( ) {
856
- replaceWasCalled = true ;
857
- originalReplaceFn . call ( $location ) ;
858
- } ;
859
- $location . replace = decoratedReplaceFn ;
847
+ spyOn ( $location , 'replace' ) ;
860
848
861
849
$state . transitionTo ( 'about' ) ;
862
850
$q . flush ( ) ;
863
851
864
- expect ( replaceWasCalled ) . toEqual ( false ) ;
852
+ expect ( $location . replace ) . not . toHaveBeenCalled ( ) ;
853
+
865
854
} ) ) ;
866
855
} ) ;
867
856
0 commit comments