@@ -15,11 +15,11 @@ import pointerMock from '../../helpers/pointerMock.js';
1515import support from '__internal/core/utils/m_support' ;
1616import typeUtils from 'core/utils/type' ;
1717import uiDateUtils from '__internal/ui/date_box/date_utils' ;
18+ import DateBox from 'ui/date_box' ;
1819import { normalizeKeyName } from 'common/core/events/utils/index' ;
1920
2021import '../../helpers/calendarFixtures.js' ;
2122
22- import 'ui/date_box' ;
2323import 'ui/validator' ;
2424import 'fluent_blue_light.css!' ;
2525
@@ -3395,6 +3395,7 @@ QUnit.module('Global formatting config (spec)', {
33953395 globalConfig [ key ] = value ;
33963396 }
33973397 } ) ;
3398+ DateBox . defaultOptions ( [ ] ) ;
33983399 } ,
33993400} , ( ) => {
34003401 QUnit . test ( 'implicit date displayFormat uses global dateFormat' , function ( assert ) {
@@ -3403,13 +3404,14 @@ QUnit.module('Global formatting config (spec)', {
34033404 dateFormat : 'dd/MM/yyyy' ,
34043405 } ) ;
34053406
3406- const instance = $ ( '#dateBox' ) . dxDateBox ( {
3407+ const $element = $ ( '#dateBox' ) . dxDateBox ( {
34073408 type : 'date' ,
34083409 value : new Date ( 2020 , 0 , 2 ) ,
34093410 pickerType : 'calendar' ,
3410- } ) . dxDateBox ( 'instance' ) ;
3411+ } ) ;
3412+ const $input = $element . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
34113413
3412- assert . strictEqual ( instance . option ( 'text' ) , '02/01/2020' ) ;
3414+ assert . strictEqual ( $input . val ( ) , '02/01/2020' ) ;
34133415 } ) ;
34143416
34153417 QUnit . test ( 'implicit datetime displayFormat uses global dateTimeFormat' , function ( assert ) {
@@ -3418,13 +3420,30 @@ QUnit.module('Global formatting config (spec)', {
34183420 dateTimeFormat : 'dd/MM/yyyy, HH:mm' ,
34193421 } ) ;
34203422
3421- const instance = $ ( '#dateBox' ) . dxDateBox ( {
3423+ const $element = $ ( '#dateBox' ) . dxDateBox ( {
34223424 type : 'datetime' ,
34233425 value : new Date ( 2020 , 0 , 2 , 14 , 5 ) ,
34243426 pickerType : 'calendar' ,
3425- } ) . dxDateBox ( 'instance' ) ;
3427+ } ) ;
3428+ const $input = $element . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
34263429
3427- assert . strictEqual ( instance . option ( 'text' ) , '02/01/2020, 14:05' ) ;
3430+ assert . strictEqual ( $input . val ( ) , '02/01/2020, 14:05' ) ;
3431+ } ) ;
3432+
3433+ QUnit . test ( 'implicit time displayFormat uses global timeFormat' , function ( assert ) {
3434+ config ( {
3435+ ...config ( ) ,
3436+ timeFormat : 'HH:mm:ss' ,
3437+ } ) ;
3438+
3439+ const $element = $ ( '#dateBox' ) . dxDateBox ( {
3440+ type : 'time' ,
3441+ value : new Date ( 2020 , 0 , 2 , 14 , 5 , 6 ) ,
3442+ pickerType : 'calendar' ,
3443+ } ) ;
3444+ const $input = $element . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
3445+
3446+ assert . strictEqual ( $input . val ( ) , '14:05:06' ) ;
34283447 } ) ;
34293448
34303449 QUnit . test ( 'explicit displayFormat keeps priority over global dateFormat' , function ( assert ) {
@@ -3433,14 +3452,36 @@ QUnit.module('Global formatting config (spec)', {
34333452 dateFormat : 'dd/MM/yyyy' ,
34343453 } ) ;
34353454
3436- const instance = $ ( '#dateBox' ) . dxDateBox ( {
3455+ const $element = $ ( '#dateBox' ) . dxDateBox ( {
34373456 type : 'date' ,
34383457 value : new Date ( 2020 , 0 , 2 ) ,
34393458 displayFormat : 'shortDate' ,
34403459 pickerType : 'calendar' ,
3441- } ) . dxDateBox ( 'instance' ) ;
3460+ } ) ;
3461+ const $input = $element . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
3462+
3463+ assert . strictEqual ( $input . val ( ) , '1/2/2020' ) ;
3464+ } ) ;
34423465
3443- assert . strictEqual ( instance . option ( 'text' ) , '1/2/2020' ) ;
3466+ QUnit . test ( 'defaultOptions displayFormat keeps priority over global dateFormat' , function ( assert ) {
3467+ config ( {
3468+ ...config ( ) ,
3469+ dateFormat : 'dd/MM/yyyy' ,
3470+ } ) ;
3471+ DateBox . defaultOptions ( {
3472+ options : {
3473+ displayFormat : 'yyyy-MM-dd' ,
3474+ } ,
3475+ } ) ;
3476+
3477+ const $element = $ ( '#dateBox' ) . dxDateBox ( {
3478+ type : 'date' ,
3479+ value : new Date ( 2020 , 0 , 2 ) ,
3480+ pickerType : 'calendar' ,
3481+ } ) ;
3482+ const $input = $element . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
3483+
3484+ assert . strictEqual ( $input . val ( ) , '2020-01-02' ) ;
34443485 } ) ;
34453486
34463487 QUnit . test ( 'implicit DateBox uses dateTimeFormatPresets.shortDate when no dateFormat is set' , function ( assert ) {
@@ -3451,13 +3492,14 @@ QUnit.module('Global formatting config (spec)', {
34513492 } ,
34523493 } ) ;
34533494
3454- const instance = $ ( '#dateBox' ) . dxDateBox ( {
3495+ const $element = $ ( '#dateBox' ) . dxDateBox ( {
34553496 type : 'date' ,
34563497 value : new Date ( 2020 , 0 , 2 ) ,
34573498 pickerType : 'calendar' ,
3458- } ) . dxDateBox ( 'instance' ) ;
3499+ } ) ;
3500+ const $input = $element . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
34593501
3460- assert . strictEqual ( instance . option ( 'text' ) , '02/01/2020' ) ;
3502+ assert . strictEqual ( $input . val ( ) , '02/01/2020' ) ;
34613503 } ) ;
34623504
34633505 QUnit . test ( 'dateFormat takes priority over dateTimeFormatPresets.shortDate for implicit DateBox' , function ( assert ) {
@@ -3469,14 +3511,15 @@ QUnit.module('Global formatting config (spec)', {
34693511 } ,
34703512 } ) ;
34713513
3472- const instance = $ ( '#dateBox' ) . dxDateBox ( {
3514+ const $element = $ ( '#dateBox' ) . dxDateBox ( {
34733515 type : 'date' ,
34743516 value : new Date ( 2020 , 0 , 2 ) ,
34753517 pickerType : 'calendar' ,
3476- } ) . dxDateBox ( 'instance' ) ;
3518+ } ) ;
3519+ const $input = $element . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
34773520
34783521 // dateFormat wins over dateTimeFormatPresets for implicit case
3479- assert . strictEqual ( instance . option ( 'text' ) , '2020-01-02' ) ;
3522+ assert . strictEqual ( $input . val ( ) , '2020-01-02' ) ;
34803523 } ) ;
34813524
34823525 QUnit . test ( 'explicit displayFormat: "shortDate" uses dateTimeFormatPresets override' , function ( assert ) {
@@ -3487,13 +3530,14 @@ QUnit.module('Global formatting config (spec)', {
34873530 } ,
34883531 } ) ;
34893532
3490- const instance = $ ( '#dateBox' ) . dxDateBox ( {
3533+ const $element = $ ( '#dateBox' ) . dxDateBox ( {
34913534 type : 'date' ,
34923535 value : new Date ( 2020 , 0 , 2 ) ,
34933536 displayFormat : 'shortDate' ,
34943537 pickerType : 'calendar' ,
3495- } ) . dxDateBox ( 'instance' ) ;
3538+ } ) ;
3539+ const $input = $element . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
34963540
3497- assert . strictEqual ( instance . option ( 'text' ) , '02/01/2020' ) ;
3541+ assert . strictEqual ( $input . val ( ) , '02/01/2020' ) ;
34983542 } ) ;
34993543} ) ;
0 commit comments