@@ -71,12 +71,49 @@ describe('dropdownSelector', function () {
7171 dropdownLink . dropdown ( ) . trigger ( 'click' ) ;
7272 expect ( parent . hasClass ( 'open' ) ) . toBeTruthy ( ) ;
7373
74+ var dropDownSpy = spyOn ( jQuery . fn , 'dropdown' ) . and . callThrough ( ) ;
75+
76+ var pastElement = jQuery ( '.past' , element ) ;
77+ pastElement . trigger ( 'click' ) ;
78+
79+ expect ( $rootScope . date ) . toEqual ( moment ( '2009-01-01T00:00:00.000' ) . toDate ( ) ) ;
80+ expect ( dropDownSpy ) . toHaveBeenCalledWith ( 'toggle' ) ;
81+ } ) ;
82+ } ) ;
83+ describe ( 'does NOT toggle dropdown' , function ( ) {
84+ it ( 'if dropdownSelector is NOT specified' , function ( ) {
85+
86+ var html = '<div class="dropdown">' +
87+ '<a class="dropdown-toggle" id="dropdown" role="button" data-toggle="dropdown" data-target="#" href="#">' +
88+ ' <div class="input-group">' +
89+ ' <input type="text" class="form-control" data-ng-model="data.dateDropDownInputNoFormatting">' +
90+ ' <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>' +
91+ ' </div>' +
92+ '</a>' +
93+ '<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">' +
94+ ' <datetimepicker data-ng-model="date" data-datetimepicker-config="{ startView: \'year\', minView: \'year\' }"></datetimepicker>' +
95+ '</ul>' +
96+ '</div>' ;
97+
98+ var element = $compile ( html ) ( $rootScope ) ;
99+ $rootScope . $digest ( ) ;
100+
101+ expect ( $rootScope . date ) . toEqual ( null ) ;
102+
103+ var dropdownLink = jQuery ( '#dropdown' , element ) ;
104+ var parent = dropdownLink . parent ( 'div.dropdown' ) ;
105+ expect ( parent . hasClass ( 'open' ) ) . toBeFalsy ( ) ;
106+
107+ dropdownLink . dropdown ( ) . trigger ( 'click' ) ;
108+ expect ( parent . hasClass ( 'open' ) ) . toBeTruthy ( ) ;
109+
110+ var dropDownSpy = spyOn ( jQuery . fn , 'dropdown' ) . and . callThrough ( ) ;
111+
74112 var pastElement = jQuery ( '.past' , element ) ;
75113 pastElement . trigger ( 'click' ) ;
76114
77115 expect ( $rootScope . date ) . toEqual ( moment ( '2009-01-01T00:00:00.000' ) . toDate ( ) ) ;
78- // ToDo: The open class should be removed after click. For some reason it is not.
79- // expect(parent.hasClass('open')).toBeFalsy(); // Always truthy for some reason.
116+ expect ( dropDownSpy ) . not . toHaveBeenCalled ( ) ;
80117 } ) ;
81118 } ) ;
82119} ) ;
0 commit comments