@@ -63,20 +63,23 @@ describe('Public API method tests', function () {
6363 dpChangeSpy ,
6464 dpShowSpy ,
6565 dpHideSpy ,
66- dpErrorSpy ;
66+ dpErrorSpy ,
67+ dpClassifySpy ;
6768
6869 beforeEach ( function ( ) {
6970 dpChangeSpy = jasmine . createSpy ( 'dp.change event Spy' ) ;
7071 dpShowSpy = jasmine . createSpy ( 'dp.show event Spy' ) ;
7172 dpHideSpy = jasmine . createSpy ( 'dp.hide event Spy' ) ;
7273 dpErrorSpy = jasmine . createSpy ( 'dp.error event Spy' ) ;
74+ dpClassifySpy = jasmine . createSpy ( 'dp.classify event Spy' ) ;
7375 dtpElement = $ ( '<input>' ) . attr ( 'id' , 'dtp' ) ;
7476
7577 $ ( document ) . find ( 'body' ) . append ( $ ( '<div>' ) . attr ( 'class' , 'row' ) . append ( $ ( '<div>' ) . attr ( 'class' , 'col-md-12' ) . append ( dtpElement ) ) ) ;
7678 $ ( document ) . find ( 'body' ) . on ( 'dp.change' , dpChangeSpy ) ;
7779 $ ( document ) . find ( 'body' ) . on ( 'dp.show' , dpShowSpy ) ;
7880 $ ( document ) . find ( 'body' ) . on ( 'dp.hide' , dpHideSpy ) ;
7981 $ ( document ) . find ( 'body' ) . on ( 'dp.error' , dpErrorSpy ) ;
82+ $ ( document ) . find ( 'body' ) . on ( 'dp.classify' , dpClassifySpy ) ;
8083
8184 dtpElement . datetimepicker ( ) ;
8285 dtp = dtpElement . data ( 'DateTimePicker' ) ;
@@ -290,10 +293,29 @@ describe('Public API method tests', function () {
290293 expect ( dpShowSpy ) . not . toHaveBeenCalled ( ) ;
291294 } ) ;
292295
296+ it ( 'calls the classify event for each day that is shown' , function ( ) {
297+ dtp . show ( ) ;
298+ expect ( dpClassifySpy . calls . count ( ) ) . toEqual ( 42 ) ;
299+ } ) ;
300+
293301 it ( 'actually shows the widget' , function ( ) {
294302 dtp . show ( ) ;
295303 expect ( $ ( document ) . find ( 'body' ) . find ( '.bootstrap-datetimepicker-widget' ) . length ) . toEqual ( 1 ) ;
296304 } ) ;
305+
306+ it ( 'applies the styles appended in the classify event handler' , function ( ) {
307+ var handler = function ( event ) {
308+ if ( event . date . get ( 'weekday' ) === 4 ) {
309+ event . classNames . push ( 'humpday' ) ;
310+ }
311+ event . classNames . push ( 'injected' ) ;
312+ } ;
313+ $ ( document ) . find ( 'body' ) . on ( 'dp.classify' , handler ) ;
314+ dtp . show ( ) ;
315+ $ ( document ) . find ( 'body' ) . off ( 'dp.classify' , handler ) ;
316+ expect ( $ ( document ) . find ( 'body' ) . find ( '.bootstrap-datetimepicker-widget td.day.injected' ) . length ) . toEqual ( 42 ) ;
317+ expect ( $ ( document ) . find ( 'body' ) . find ( '.bootstrap-datetimepicker-widget td.day.humpday' ) . length ) . toEqual ( 6 ) ;
318+ } ) ;
297319 } ) ;
298320
299321 describe ( 'access' , function ( ) {
0 commit comments