1
- describe ( 'alert' , function ( ) {
1
+ describe ( 'uib- alert' , function ( ) {
2
2
var element , scope , $compile , $templateCache , $timeout ;
3
3
4
4
beforeEach ( module ( 'ui.bootstrap.alert' ) ) ;
@@ -12,9 +12,9 @@ describe('alert', function() {
12
12
13
13
element = angular . element (
14
14
'<div>' +
15
- '<alert ng-repeat="alert in alerts" type="{{alert.type}}"' +
15
+ '<uib- alert ng-repeat="alert in alerts" type="{{alert.type}}"' +
16
16
'close="removeAlert($index)">{{alert.msg}}' +
17
- '</alert>' +
17
+ '</uib- alert>' +
18
18
'</div>' ) ;
19
19
20
20
scope . alerts = [
@@ -41,10 +41,10 @@ describe('alert', function() {
41
41
it ( 'should expose the controller to the view' , function ( ) {
42
42
$templateCache . put ( 'template/alert/alert.html' , '<div>{{alert.text}}</div>' ) ;
43
43
44
- element = $compile ( '<alert></alert>' ) ( scope ) ;
44
+ element = $compile ( '<uib- alert></uib- alert>' ) ( scope ) ;
45
45
scope . $digest ( ) ;
46
46
47
- var ctrl = element . controller ( 'alert' ) ;
47
+ var ctrl = element . controller ( 'uib- alert' ) ;
48
48
expect ( ctrl ) . toBeDefined ( ) ;
49
49
50
50
ctrl . text = 'foo' ;
@@ -56,7 +56,7 @@ describe('alert', function() {
56
56
it ( 'should support custom templates' , function ( ) {
57
57
$templateCache . put ( 'foo/bar.html' , '<div>baz</div>' ) ;
58
58
59
- element = $compile ( '<alert template-url="foo/bar.html"></alert>' ) ( scope ) ;
59
+ element = $compile ( '<uib- alert template-url="foo/bar.html"></uib- alert>' ) ( scope ) ;
60
60
scope . $digest ( ) ;
61
61
62
62
expect ( element . html ( ) ) . toBe ( 'baz' ) ;
@@ -115,25 +115,58 @@ describe('alert', function() {
115
115
} ) ;
116
116
117
117
it ( 'should not show close button and have the dismissible class if no close callback specified' , function ( ) {
118
- element = $compile ( '<alert>No close</alert>' ) ( scope ) ;
118
+ element = $compile ( '<uib- alert>No close</uib- alert>' ) ( scope ) ;
119
119
scope . $digest ( ) ;
120
120
expect ( findCloseButton ( 0 ) ) . toBeHidden ( ) ;
121
121
expect ( element ) . not . toHaveClass ( 'alert-dismissible' ) ;
122
122
} ) ;
123
123
124
124
it ( 'should be possible to add additional classes for alert' , function ( ) {
125
- var element = $compile ( '<alert class="alert-block" type="info">Default alert!</alert>' ) ( scope ) ;
125
+ var element = $compile ( '<uib- alert class="alert-block" type="info">Default alert!</uib- alert>' ) ( scope ) ;
126
126
scope . $digest ( ) ;
127
127
expect ( element ) . toHaveClass ( 'alert-block' ) ;
128
128
expect ( element ) . toHaveClass ( 'alert-info' ) ;
129
129
} ) ;
130
130
131
131
it ( 'should close automatically if dismiss-on-timeout is defined on the element' , function ( ) {
132
132
scope . removeAlert = jasmine . createSpy ( ) ;
133
- $compile ( '<alert close="removeAlert()" dismiss-on-timeout="500">Default alert!</alert>' ) ( scope ) ;
133
+ $compile ( '<uib- alert close="removeAlert()" dismiss-on-timeout="500">Default alert!</uib- alert>' ) ( scope ) ;
134
134
scope . $digest ( ) ;
135
135
136
136
$timeout . flush ( ) ;
137
137
expect ( scope . removeAlert ) . toHaveBeenCalled ( ) ;
138
138
} ) ;
139
139
} ) ;
140
+
141
+ /* Deprecation tests below */
142
+
143
+ describe ( 'alert deprecation' , function ( ) {
144
+ beforeEach ( module ( 'ui.bootstrap.alert' ) ) ;
145
+ beforeEach ( module ( 'template/alert/alert.html' ) ) ;
146
+
147
+ it ( 'should suppress warning' , function ( ) {
148
+ module ( function ( $provide ) {
149
+ $provide . value ( '$alertSuppressWarning' , true ) ;
150
+ } ) ;
151
+
152
+ inject ( function ( $compile , $log , $rootScope ) {
153
+ spyOn ( $log , 'warn' ) ;
154
+
155
+ var element = '<alert></alert>' ;
156
+ element = $compile ( element ) ( $rootScope ) ;
157
+ $rootScope . $digest ( ) ;
158
+ expect ( $log . warn . calls . count ( ) ) . toBe ( 0 ) ;
159
+ } ) ;
160
+ } ) ;
161
+
162
+ it ( 'should give warning by default' , inject ( function ( $compile , $log , $rootScope ) {
163
+ spyOn ( $log , 'warn' ) ;
164
+
165
+ var element = '<alert></alert>' ;
166
+ element = $compile ( element ) ( $rootScope ) ;
167
+ $rootScope . $digest ( ) ;
168
+
169
+ expect ( $log . warn . calls . count ( ) ) . toBe ( 1 ) ;
170
+ expect ( $log . warn . calls . argsFor ( 0 ) ) . toEqual ( [ 'alert is now deprecated. Use uib-alert instead.' ] ) ;
171
+ } ) ) ;
172
+ } ) ;
0 commit comments