@@ -178,6 +178,22 @@ describe('datepicker:', () => {
178
178
expect ( buttonText . filter ( button => button === clearBtnCustomLbl ) . length ) . toEqual ( 1 ) ;
179
179
} ) ;
180
180
181
+ it ( 'should show custom label for custom button if set in config' , ( ) => {
182
+ const customBtnCustomLbl = 'Clear current' ;
183
+ const datepickerDirective = getDatepickerDirective ( fixture ) ;
184
+ datepickerDirective . bsConfig = {
185
+ customButtonLabel : customBtnCustomLbl ,
186
+ customDateButton : new Date ( )
187
+ } ;
188
+ showDatepicker ( fixture ) ;
189
+
190
+ const buttonText : string [ ] = [ ] ;
191
+ // fixture.debugElement.queryAll(By.css('button'))
192
+ Array . from ( document . body . getElementsByTagName ( 'button' ) )
193
+ . forEach ( button => buttonText . push ( button . textContent ) ) ;
194
+ expect ( buttonText . filter ( button => button === customBtnCustomLbl ) . length ) . toEqual ( 1 ) ;
195
+ } ) ;
196
+
181
197
describe ( 'should start with' , ( ) => {
182
198
183
199
const parameters = [
@@ -257,6 +273,37 @@ describe('datepicker:', () => {
257
273
} ) . unsubscribe ( ) ;
258
274
} ) ;
259
275
276
+ it ( 'should set custom date' , ( ) => {
277
+ const datepicker = showDatepicker ( fixture ) ;
278
+ const datepickerContainerInstance = getDatepickerContainer ( datepicker ) ;
279
+ const customDate = new Date ( 2099 , 11 , 31 )
280
+ datepickerContainerInstance . customDateBtn = customDate ;
281
+
282
+ datepickerContainerInstance [ `_store` ]
283
+ . select ( state => state . view )
284
+ . subscribe ( view => {
285
+ view . date = new Date ( 2020 , 0 , 1 ) ;
286
+ } ) . unsubscribe ( ) ;
287
+ fixture . detectChanges ( ) ;
288
+
289
+ datepickerContainerInstance [ `_store` ]
290
+ . select ( state => state . view )
291
+ . subscribe ( view => {
292
+ expect ( `${ ( view . date . getDate ( ) ) } -${ ( view . date . getMonth ( ) ) } -${ ( view . date . getFullYear ( ) ) } ` )
293
+ . not . toEqual ( `${ ( customDate . getDate ( ) ) } -${ ( customDate . getMonth ( ) ) } -${ ( customDate . getFullYear ( ) ) } ` ) ;
294
+ } ) . unsubscribe ( ) ;
295
+
296
+ datepickerContainerInstance . setCustomDate ( ) ;
297
+ fixture . detectChanges ( ) ;
298
+
299
+ datepickerContainerInstance [ `_store` ]
300
+ . select ( state => state . view )
301
+ . subscribe ( view => {
302
+ expect ( `${ ( view . date . getDate ( ) ) } -${ ( view . date . getMonth ( ) ) } -${ ( view . date . getFullYear ( ) ) } ` )
303
+ . toEqual ( `${ ( customDate . getDate ( ) ) } -${ ( customDate . getMonth ( ) ) } -${ ( customDate . getFullYear ( ) ) } ` ) ;
304
+ } ) . unsubscribe ( ) ;
305
+ } ) ;
306
+
260
307
it ( 'should clear date' , ( ) => {
261
308
const datepicker = showDatepicker ( fixture ) ;
262
309
const datepickerContainerInstance = getDatepickerContainer ( datepicker ) ;
0 commit comments