@@ -826,7 +826,15 @@ describe('$location', function() {
826826 initLocation ( ) ,
827827 function ( $browser ) {
828828 browserTrigger ( link , 'click' ) ;
829- expectNoRewrite ( $browser , 'http://host.com/base/' ) ;
829+ expectRewriteTo ( $browser , 'http://host.com/base/' ) ;
830+
831+ jqLite ( link ) . attr ( 'href' , 'http://host.com/base/foo' ) ;
832+ browserTrigger ( link , 'click' ) ;
833+ expectRewriteTo ( $browser , 'http://host.com/base/foo' ) ;
834+
835+ jqLite ( link ) . attr ( 'href' , 'http://host.com/base/' ) ;
836+ browserTrigger ( link , 'click' ) ;
837+ expectRewriteTo ( $browser , 'http://host.com/base/' ) ;
830838 }
831839 ) ;
832840 } ) ;
@@ -1332,4 +1340,58 @@ describe('$location', function() {
13321340 } ) ;
13331341 } ) ;
13341342 } ) ;
1343+
1344+ describe ( 'LocationHtml5Url' , function ( ) {
1345+ var location , locationIndex ;
1346+
1347+ beforeEach ( function ( ) {
1348+ location = new LocationHtml5Url ( 'http://server/pre/' , 'http://server/pre/path' ) ;
1349+ locationIndex = new LocationHtml5Url ( 'http://server/pre/index.html' , 'http://server/pre/path' ) ;
1350+ } ) ;
1351+
1352+ it ( 'should rewrite URL' , function ( ) {
1353+ expect ( location . $$rewrite ( 'http://other' ) ) . toEqual ( undefined ) ;
1354+ expect ( location . $$rewrite ( 'http://server/pre' ) ) . toEqual ( 'http://server/pre/' ) ;
1355+ expect ( location . $$rewrite ( 'http://server/pre/' ) ) . toEqual ( 'http://server/pre/' ) ;
1356+ expect ( location . $$rewrite ( 'http://server/pre/otherPath' ) ) . toEqual ( 'http://server/pre/otherPath' ) ;
1357+ expect ( locationIndex . $$rewrite ( 'http://server/pre' ) ) . toEqual ( 'http://server/pre/' ) ;
1358+ expect ( locationIndex . $$rewrite ( 'http://server/pre/' ) ) . toEqual ( 'http://server/pre/' ) ;
1359+ expect ( locationIndex . $$rewrite ( 'http://server/pre/otherPath' ) ) . toEqual ( 'http://server/pre/otherPath' ) ;
1360+ } ) ;
1361+ } ) ;
1362+
1363+
1364+ describe ( 'LocationHashbangUrl' , function ( ) {
1365+ var location ;
1366+
1367+ beforeEach ( function ( ) {
1368+ location = new LocationHashbangUrl ( 'http://server/pre/' , 'http://server/pre/#/path' ) ;
1369+ } ) ;
1370+
1371+ it ( 'should rewrite URL' , function ( ) {
1372+ expect ( location . $$rewrite ( 'http://other' ) ) . toEqual ( undefined ) ;
1373+ expect ( location . $$rewrite ( 'http://server/pre/' ) ) . toEqual ( 'http://server/pre/' ) ;
1374+ expect ( location . $$rewrite ( 'http://server/pre/#otherPath' ) ) . toEqual ( 'http://server/pre/#otherPath' ) ;
1375+ } ) ;
1376+ } ) ;
1377+
1378+
1379+ describe ( 'LocationHashbangInHtml5Url' , function ( ) {
1380+ var location , locationIndex ;
1381+
1382+ beforeEach ( function ( ) {
1383+ location = new LocationHashbangInHtml5Url ( 'http://server/pre/' , '#!' ) ;
1384+ locationIndex = new LocationHashbangInHtml5Url ( 'http://server/pre/index.html' , '#!' ) ;
1385+ } ) ;
1386+
1387+ it ( 'should rewrite URL' , function ( ) {
1388+ expect ( location . $$rewrite ( 'http://other' ) ) . toEqual ( undefined ) ;
1389+ expect ( location . $$rewrite ( 'http://server/pre' ) ) . toEqual ( 'http://server/pre/' ) ;
1390+ expect ( location . $$rewrite ( 'http://server/pre/' ) ) . toEqual ( 'http://server/pre/' ) ;
1391+ expect ( location . $$rewrite ( 'http://server/pre/otherPath' ) ) . toEqual ( 'http://server/pre/#!otherPath' ) ;
1392+ expect ( locationIndex . $$rewrite ( 'http://server/pre' ) ) . toEqual ( 'http://server/pre/' ) ;
1393+ expect ( locationIndex . $$rewrite ( 'http://server/pre/' ) ) . toEqual ( undefined ) ;
1394+ expect ( locationIndex . $$rewrite ( 'http://server/pre/otherPath' ) ) . toEqual ( 'http://server/pre/index.html#!otherPath' ) ;
1395+ } ) ;
1396+ } ) ;
13351397} ) ;
0 commit comments