@@ -9,7 +9,7 @@ describe('timepicker directive', function() {
9
9
$rootScope . time = newTime ( 14 , 40 ) ;
10
10
$templateCache = _$templateCache_ ;
11
11
12
- element = $compile ( '<timepicker ng-model="time"></timepicker>' ) ( $rootScope ) ;
12
+ element = $compile ( '<uib- timepicker ng-model="time"></uib- timepicker>' ) ( $rootScope ) ;
13
13
$rootScope . $digest ( ) ;
14
14
} ) ) ;
15
15
@@ -107,7 +107,7 @@ describe('timepicker directive', function() {
107
107
108
108
it ( 'has `selected` current time when model is initially cleared' , function ( ) {
109
109
$rootScope . time = null ;
110
- element = $compile ( '<timepicker ng-model="time"></timepicker>' ) ( $rootScope ) ;
110
+ element = $compile ( '<uib- timepicker ng-model="time"></uib- timepicker>' ) ( $rootScope ) ;
111
111
$rootScope . $digest ( ) ;
112
112
113
113
expect ( $rootScope . time ) . toBe ( null ) ;
@@ -272,7 +272,7 @@ describe('timepicker directive', function() {
272
272
} ) ;
273
273
274
274
it ( 'changes only the time part when minutes change' , function ( ) {
275
- element = $compile ( '<timepicker ng-model="time" minute-step="15"></timepicker>' ) ( $rootScope ) ;
275
+ element = $compile ( '<uib- timepicker ng-model="time" minute-step="15"></uib- timepicker>' ) ( $rootScope ) ;
276
276
$rootScope . time = newTime ( 0 , 0 ) ;
277
277
$rootScope . $digest ( ) ;
278
278
@@ -468,7 +468,7 @@ describe('timepicker directive', function() {
468
468
$rootScope . hstep = 2 ;
469
469
$rootScope . mstep = 30 ;
470
470
$rootScope . time = newTime ( 14 , 0 ) ;
471
- element = $compile ( '<timepicker ng-model="time" hour-step="hstep" minute-step="mstep"></timepicker>' ) ( $rootScope ) ;
471
+ element = $compile ( '<uib- timepicker ng-model="time" hour-step="hstep" minute-step="mstep"></uib- timepicker>' ) ( $rootScope ) ;
472
472
$rootScope . $digest ( ) ;
473
473
} ) ;
474
474
@@ -631,7 +631,7 @@ describe('timepicker directive', function() {
631
631
beforeEach ( function ( ) {
632
632
$rootScope . meridian = false ;
633
633
$rootScope . time = newTime ( 14 , 10 ) ;
634
- element = $compile ( '<timepicker ng-model="time" show-meridian="meridian"></timepicker>' ) ( $rootScope ) ;
634
+ element = $compile ( '<uib- timepicker ng-model="time" show-meridian="meridian"></uib- timepicker>' ) ( $rootScope ) ;
635
635
$rootScope . $digest ( ) ;
636
636
} ) ;
637
637
@@ -663,7 +663,7 @@ describe('timepicker directive', function() {
663
663
664
664
it ( 'handles correctly initially empty model on parent element' , function ( ) {
665
665
$rootScope . time = null ;
666
- element = $compile ( '<span ng-model="time"><timepicker show-meridian="meridian"></timepicker></span>' ) ( $rootScope ) ;
666
+ element = $compile ( '<span ng-model="time"><uib- timepicker show-meridian="meridian"></uib- timepicker></span>' ) ( $rootScope ) ;
667
667
$rootScope . $digest ( ) ;
668
668
669
669
expect ( $rootScope . time ) . toBe ( null ) ;
@@ -673,7 +673,7 @@ describe('timepicker directive', function() {
673
673
describe ( '`meridians` attribute' , function ( ) {
674
674
beforeEach ( inject ( function ( ) {
675
675
$rootScope . meridiansArray = [ 'am' , 'pm' ] ;
676
- element = $compile ( '<timepicker ng-model="time" meridians="meridiansArray"></timepicker>' ) ( $rootScope ) ;
676
+ element = $compile ( '<uib- timepicker ng-model="time" meridians="meridiansArray"></uib- timepicker>' ) ( $rootScope ) ;
677
677
$rootScope . $digest ( ) ;
678
678
} ) ) ;
679
679
@@ -691,7 +691,7 @@ describe('timepicker directive', function() {
691
691
describe ( '`readonly-input` attribute' , function ( ) {
692
692
beforeEach ( inject ( function ( ) {
693
693
$rootScope . meridiansArray = [ 'am' , 'pm' ] ;
694
- element = $compile ( '<timepicker ng-model="time" readonly-input="true"></timepicker>' ) ( $rootScope ) ;
694
+ element = $compile ( '<uib- timepicker ng-model="time" readonly-input="true"></uib- timepicker>' ) ( $rootScope ) ;
695
695
$rootScope . $digest ( ) ;
696
696
} ) ) ;
697
697
@@ -704,17 +704,17 @@ describe('timepicker directive', function() {
704
704
705
705
describe ( 'setting timepickerConfig steps' , function ( ) {
706
706
var originalConfig = { } ;
707
- beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , timepickerConfig ) {
708
- angular . extend ( originalConfig , timepickerConfig ) ;
709
- timepickerConfig . hourStep = 2 ;
710
- timepickerConfig . minuteStep = 10 ;
711
- timepickerConfig . showMeridian = false ;
712
- element = $compile ( '<timepicker ng-model="time"></timepicker>' ) ( $rootScope ) ;
707
+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , uibTimepickerConfig ) {
708
+ angular . extend ( originalConfig , uibTimepickerConfig ) ;
709
+ uibTimepickerConfig . hourStep = 2 ;
710
+ uibTimepickerConfig . minuteStep = 10 ;
711
+ uibTimepickerConfig . showMeridian = false ;
712
+ element = $compile ( '<uib- timepicker ng-model="time"></uib- timepicker>' ) ( $rootScope ) ;
713
713
$rootScope . $digest ( ) ;
714
714
} ) ) ;
715
- afterEach ( inject ( function ( timepickerConfig ) {
715
+ afterEach ( inject ( function ( uibTimepickerConfig ) {
716
716
// return it to the original state
717
- angular . extend ( timepickerConfig , originalConfig ) ;
717
+ angular . extend ( uibTimepickerConfig , originalConfig ) ;
718
718
} ) ) ;
719
719
720
720
it ( 'does not affect the initial value' , function ( ) {
@@ -751,16 +751,16 @@ describe('timepicker directive', function() {
751
751
752
752
describe ( 'setting timepickerConfig meridian labels' , function ( ) {
753
753
var originalConfig = { } ;
754
- beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , timepickerConfig ) {
755
- angular . extend ( originalConfig , timepickerConfig ) ;
756
- timepickerConfig . meridians = [ 'π.μ.' , 'μ.μ.' ] ;
757
- timepickerConfig . showMeridian = true ;
758
- element = $compile ( '<timepicker ng-model="time"></timepicker>' ) ( $rootScope ) ;
754
+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , uibTimepickerConfig ) {
755
+ angular . extend ( originalConfig , uibTimepickerConfig ) ;
756
+ uibTimepickerConfig . meridians = [ 'π.μ.' , 'μ.μ.' ] ;
757
+ uibTimepickerConfig . showMeridian = true ;
758
+ element = $compile ( '<uib- timepicker ng-model="time"></uib- timepicker>' ) ( $rootScope ) ;
759
759
$rootScope . $digest ( ) ;
760
760
} ) ) ;
761
- afterEach ( inject ( function ( timepickerConfig ) {
761
+ afterEach ( inject ( function ( uibTimepickerConfig ) {
762
762
// return it to the original state
763
- angular . extend ( timepickerConfig , originalConfig ) ;
763
+ angular . extend ( uibTimepickerConfig , originalConfig ) ;
764
764
} ) ) ;
765
765
766
766
it ( 'displays correctly' , function ( ) {
@@ -921,7 +921,7 @@ describe('timepicker directive', function() {
921
921
922
922
it ( 'handles 12/24H mode change' , function ( ) {
923
923
$rootScope . meridian = true ;
924
- element = $compile ( '<timepicker ng-model="time" show-meridian="meridian"></timepicker>' ) ( $rootScope ) ;
924
+ element = $compile ( '<uib- timepicker ng-model="time" show-meridian="meridian"></uib- timepicker>' ) ( $rootScope ) ;
925
925
$rootScope . $digest ( ) ;
926
926
927
927
var el = getHoursInputEl ( ) ;
@@ -941,7 +941,7 @@ describe('timepicker directive', function() {
941
941
942
942
describe ( 'when model is not a Date' , function ( ) {
943
943
beforeEach ( inject ( function ( ) {
944
- element = $compile ( '<timepicker ng-model="time"></timepicker>' ) ( $rootScope ) ;
944
+ element = $compile ( '<uib- timepicker ng-model="time"></uib- timepicker>' ) ( $rootScope ) ;
945
945
} ) ) ;
946
946
947
947
it ( 'should not be invalid when the model is null' , function ( ) {
@@ -993,7 +993,7 @@ describe('timepicker directive', function() {
993
993
describe ( 'use with `ng-required` directive' , function ( ) {
994
994
beforeEach ( inject ( function ( ) {
995
995
$rootScope . time = null ;
996
- element = $compile ( '<timepicker ng-model="time" ng-required="true"></timepicker>' ) ( $rootScope ) ;
996
+ element = $compile ( '<uib- timepicker ng-model="time" ng-required="true"></uib- timepicker>' ) ( $rootScope ) ;
997
997
$rootScope . $digest ( ) ;
998
998
} ) ) ;
999
999
@@ -1012,7 +1012,7 @@ describe('timepicker directive', function() {
1012
1012
beforeEach ( inject ( function ( ) {
1013
1013
$rootScope . changeHandler = jasmine . createSpy ( 'changeHandler' ) ;
1014
1014
$rootScope . time = new Date ( ) ;
1015
- element = $compile ( '<timepicker ng-model="time" ng-change="changeHandler()"></timepicker>' ) ( $rootScope ) ;
1015
+ element = $compile ( '<uib- timepicker ng-model="time" ng-change="changeHandler()"></uib- timepicker>' ) ( $rootScope ) ;
1016
1016
$rootScope . $digest ( ) ;
1017
1017
} ) ) ;
1018
1018
@@ -1040,7 +1040,7 @@ describe('timepicker directive', function() {
1040
1040
describe ( 'when used with min' , function ( ) {
1041
1041
var changeInputValueTo ;
1042
1042
beforeEach ( inject ( function ( $sniffer ) {
1043
- element = $compile ( '<timepicker ng-model="time" min="min"></timepicker>' ) ( $rootScope ) ;
1043
+ element = $compile ( '<uib- timepicker ng-model="time" min="min"></uib- timepicker>' ) ( $rootScope ) ;
1044
1044
$rootScope . $digest ( ) ;
1045
1045
changeInputValueTo = function ( inputEl , value ) {
1046
1046
inputEl . val ( value ) ;
@@ -1698,7 +1698,7 @@ describe('timepicker directive', function() {
1698
1698
it ( 'should allow custom templates' , function ( ) {
1699
1699
$templateCache . put ( 'foo/bar.html' , '<div>baz</div>' ) ;
1700
1700
1701
- element = $compile ( '<timepicker ng-model="time" template-url="foo/bar.html"></timepicker>' ) ( $rootScope ) ;
1701
+ element = $compile ( '<uib- timepicker ng-model="time" template-url="foo/bar.html"></uib- timepicker>' ) ( $rootScope ) ;
1702
1702
$rootScope . $digest ( ) ;
1703
1703
expect ( element [ 0 ] . tagName . toLowerCase ( ) ) . toBe ( 'div' ) ;
1704
1704
expect ( element . html ( ) ) . toBe ( 'baz' ) ;
@@ -1707,10 +1707,10 @@ describe('timepicker directive', function() {
1707
1707
it ( 'should expose the controller on the view' , function ( ) {
1708
1708
$templateCache . put ( 'template/timepicker/timepicker.html' , '<div><div>{{timepicker.text}}</div></div>' ) ;
1709
1709
1710
- element = $compile ( '<timepicker ng-model="time"></timepicker>' ) ( $rootScope ) ;
1710
+ element = $compile ( '<uib- timepicker ng-model="time"></uib- timepicker>' ) ( $rootScope ) ;
1711
1711
$rootScope . $digest ( ) ;
1712
1712
1713
- var ctrl = element . controller ( 'timepicker ' ) ;
1713
+ var ctrl = element . controller ( 'uibTimepicker ' ) ;
1714
1714
expect ( ctrl ) . toBeDefined ( ) ;
1715
1715
1716
1716
ctrl . text = 'foo' ;
@@ -1720,3 +1720,39 @@ describe('timepicker directive', function() {
1720
1720
} ) ;
1721
1721
} ) ;
1722
1722
} ) ;
1723
+
1724
+ /* Deprecation tests below */
1725
+
1726
+ describe ( 'timepicker deprecation' , function ( ) {
1727
+ beforeEach ( module ( 'ui.bootstrap.timepicker' ) ) ;
1728
+ beforeEach ( module ( 'ngAnimateMock' ) ) ;
1729
+ beforeEach ( module ( 'template/timepicker/timepicker.html' ) ) ;
1730
+
1731
+ it ( 'should suppress warning' , function ( ) {
1732
+ module ( function ( $provide ) {
1733
+ $provide . value ( '$timepickerSuppressWarning' , true ) ;
1734
+ } ) ;
1735
+
1736
+ inject ( function ( $compile , $log , $rootScope ) {
1737
+ spyOn ( $log , 'warn' ) ;
1738
+
1739
+ $rootScope . time = new Date ( ) . setHours ( 14 , 40 , 0 , 0 ) ;
1740
+ var element = '<timepicker ng-model="time"></timepicker>' ;
1741
+ element = $compile ( element ) ( $rootScope ) ;
1742
+ $rootScope . $digest ( ) ;
1743
+ expect ( $log . warn . calls . count ( ) ) . toBe ( 0 ) ;
1744
+ } ) ;
1745
+ } ) ;
1746
+
1747
+ it ( 'should give warning by default' , inject ( function ( $compile , $log , $rootScope ) {
1748
+ spyOn ( $log , 'warn' ) ;
1749
+
1750
+ $rootScope . time = new Date ( ) . setHours ( 14 , 40 , 0 , 0 ) ;
1751
+ var element = '<timepicker ng-model="time"></timepicker>' ;
1752
+ element = $compile ( element ) ( $rootScope ) ;
1753
+ $rootScope . $digest ( ) ;
1754
+
1755
+ expect ( $log . warn . calls . count ( ) ) . toBe ( 1 ) ;
1756
+ expect ( $log . warn . calls . argsFor ( 0 ) ) . toEqual ( [ 'timepicker is now deprecated. Use uib-timepicker instead.' ] ) ;
1757
+ } ) ) ;
1758
+ } ) ;
0 commit comments