@@ -8,21 +8,6 @@ describe('boolean attr directives', function() {
88 } ) ;
99
1010
11- it ( 'should bind href' , inject ( function ( $rootScope , $compile ) {
12- element = $compile ( '<a ng-href="{{url}}"></a>' ) ( $rootScope )
13- $rootScope . url = 'http://server' ;
14- $rootScope . $digest ( ) ;
15- expect ( element . attr ( 'href' ) ) . toEqual ( 'http://server' ) ;
16- } ) ) ;
17-
18-
19- it ( 'should bind href even if no interpolation' , inject ( function ( $rootScope , $compile ) {
20- element = $compile ( '<a ng-href="http://server"></a>' ) ( $rootScope )
21- $rootScope . $digest ( ) ;
22- expect ( element . attr ( 'href' ) ) . toEqual ( 'http://server' ) ;
23- } ) ) ;
24-
25-
2611 it ( 'should properly evaluate 0 as false' , inject ( function ( $rootScope , $compile ) {
2712 // jQuery does not treat 0 as false, when setting attr()
2813 element = $compile ( '<button ng-disabled="isDisabled">Button</button>' ) ( $rootScope )
@@ -89,24 +74,6 @@ describe('boolean attr directives', function() {
8974 $rootScope . $digest ( ) ;
9075 expect ( element . attr ( 'multiple' ) ) . toBeTruthy ( ) ;
9176 } ) ) ;
92-
93-
94- it ( 'should bind src' , inject ( function ( $rootScope , $compile ) {
95- element = $compile ( '<div ng-src="{{url}}" />' ) ( $rootScope )
96- $rootScope . url = 'http://localhost/' ;
97- $rootScope . $digest ( ) ;
98- expect ( element . attr ( 'src' ) ) . toEqual ( 'http://localhost/' ) ;
99- } ) ) ;
100-
101-
102- it ( 'should bind href and merge with other attrs' , inject ( function ( $rootScope , $compile ) {
103- element = $compile ( '<a ng-href="{{url}}" rel="{{rel}}"></a>' ) ( $rootScope ) ;
104- $rootScope . url = 'http://server' ;
105- $rootScope . rel = 'REL' ;
106- $rootScope . $digest ( ) ;
107- expect ( element . attr ( 'href' ) ) . toEqual ( 'http://server' ) ;
108- expect ( element . attr ( 'rel' ) ) . toEqual ( 'REL' ) ;
109- } ) ) ;
11077} ) ;
11178
11279
@@ -128,17 +95,38 @@ describe('ng-src', function() {
12895
12996
13097describe ( 'ng-href' , function ( ) {
98+ var element ;
99+
100+ afterEach ( function ( ) {
101+ dealoc ( element ) ;
102+ } ) ;
103+
131104
132105 it ( 'should interpolate the expression and bind to href' , inject ( function ( $compile , $rootScope ) {
133- var element = $compile ( '<div ng-href="some/{{id}}"></div>' ) ( $rootScope )
106+ element = $compile ( '<div ng-href="some/{{id}}"></div>' ) ( $rootScope )
134107 $rootScope . $digest ( ) ;
135108 expect ( element . attr ( 'href' ) ) . toEqual ( 'some/' ) ;
136109
137110 $rootScope . $apply ( function ( ) {
138111 $rootScope . id = 1 ;
139112 } ) ;
140113 expect ( element . attr ( 'href' ) ) . toEqual ( 'some/1' ) ;
114+ } ) ) ;
141115
142- dealoc ( element ) ;
116+
117+ it ( 'should bind href and merge with other attrs' , inject ( function ( $rootScope , $compile ) {
118+ element = $compile ( '<a ng-href="{{url}}" rel="{{rel}}"></a>' ) ( $rootScope ) ;
119+ $rootScope . url = 'http://server' ;
120+ $rootScope . rel = 'REL' ;
121+ $rootScope . $digest ( ) ;
122+ expect ( element . attr ( 'href' ) ) . toEqual ( 'http://server' ) ;
123+ expect ( element . attr ( 'rel' ) ) . toEqual ( 'REL' ) ;
124+ } ) ) ;
125+
126+
127+ it ( 'should bind href even if no interpolation' , inject ( function ( $rootScope , $compile ) {
128+ element = $compile ( '<a ng-href="http://server"></a>' ) ( $rootScope )
129+ $rootScope . $digest ( ) ;
130+ expect ( element . attr ( 'href' ) ) . toEqual ( 'http://server' ) ;
143131 } ) ) ;
144132} ) ;
0 commit comments