@@ -463,7 +463,7 @@ describe('Appointment Popup Form', () => {
463463
464464 POM . popup . getBackButton ( ) . click ( ) ;
465465
466- expect ( POM . popup . component . option ( 'height' ) ) . toBeUndefined ( ) ;
466+ expect ( POM . popup . component . option ( 'height' ) ) . toBe ( 'auto' ) ;
467467 expect ( mainGroup . hasClass ( CLASSES . mainGroupHidden ) ) . toBe ( false ) ;
468468 expect ( recurrenceGroup . hasClass ( CLASSES . recurrenceGroupHidden ) ) . toBe ( true ) ;
469469 } ) ;
@@ -1398,6 +1398,163 @@ describe('Appointment Popup Form', () => {
13981398 expect ( data [ 0 ] . Subject ) . toBe ( 'qwerty' ) ;
13991399 expect ( data [ 0 ] . text ) . toBeUndefined ( ) ;
14001400 } ) ;
1401+
1402+ describe ( 'Popup options' , ( ) => {
1403+ it ( 'should pass custom popup options from editing.popup to appointment popup' , async ( ) => {
1404+ const { scheduler, POM } = await createScheduler ( {
1405+ ...getDefaultConfig ( ) ,
1406+ editing : {
1407+ allowAdding : true ,
1408+ allowUpdating : true ,
1409+ popup : {
1410+ showTitle : true ,
1411+ title : 'Custom Appointment Form' ,
1412+ maxHeight : '80%' ,
1413+ dragEnabled : true ,
1414+ } ,
1415+ } ,
1416+ } ) ;
1417+
1418+ scheduler . showAppointmentPopup ( commonAppointment ) ;
1419+
1420+ expect ( POM . popup . component . option ( 'showTitle' ) ) . toBe ( true ) ;
1421+ expect ( POM . popup . component . option ( 'title' ) ) . toBe ( 'Custom Appointment Form' ) ;
1422+ expect ( POM . popup . component . option ( 'maxHeight' ) ) . toBe ( '80%' ) ;
1423+ expect ( POM . popup . component . option ( 'dragEnabled' ) ) . toBe ( true ) ;
1424+ } ) ;
1425+
1426+ it ( 'should use default popup options when editing.popup is not specified' , async ( ) => {
1427+ const { scheduler, POM } = await createScheduler ( {
1428+ ...getDefaultConfig ( ) ,
1429+ editing : {
1430+ allowAdding : true ,
1431+ allowUpdating : true ,
1432+ } ,
1433+ } ) ;
1434+
1435+ scheduler . showAppointmentPopup ( commonAppointment ) ;
1436+
1437+ expect ( POM . popup . component . option ( 'showTitle' ) ) . toBe ( false ) ;
1438+ expect ( POM . popup . component . option ( 'height' ) ) . toBe ( 'auto' ) ;
1439+ expect ( POM . popup . component . option ( 'maxHeight' ) ) . toBe ( '90%' ) ;
1440+ } ) ;
1441+
1442+ it ( 'should merge custom popup options with default options' , async ( ) => {
1443+ const { scheduler, POM } = await createScheduler ( {
1444+ ...getDefaultConfig ( ) ,
1445+ editing : {
1446+ allowAdding : true ,
1447+ allowUpdating : true ,
1448+ popup : {
1449+ showTitle : true ,
1450+ title : 'My Form' ,
1451+ } ,
1452+ } ,
1453+ } ) ;
1454+
1455+ scheduler . showAppointmentPopup ( commonAppointment ) ;
1456+
1457+ expect ( POM . popup . component . option ( 'showTitle' ) ) . toBe ( true ) ;
1458+ expect ( POM . popup . component . option ( 'title' ) ) . toBe ( 'My Form' ) ;
1459+
1460+ expect ( POM . popup . component . option ( 'showCloseButton' ) ) . toBe ( false ) ;
1461+ expect ( POM . popup . component . option ( 'enableBodyScroll' ) ) . toBe ( false ) ;
1462+ expect ( POM . popup . component . option ( 'preventScrollEvents' ) ) . toBe ( false ) ;
1463+ } ) ;
1464+
1465+ it ( 'should allow overriding default popup options' , async ( ) => {
1466+ const { scheduler, POM } = await createScheduler ( {
1467+ ...getDefaultConfig ( ) ,
1468+ editing : {
1469+ allowAdding : true ,
1470+ allowUpdating : true ,
1471+ popup : {
1472+ showCloseButton : true ,
1473+ enableBodyScroll : true ,
1474+ } ,
1475+ } ,
1476+ } ) ;
1477+
1478+ scheduler . showAppointmentPopup ( commonAppointment ) ;
1479+
1480+ expect ( POM . popup . component . option ( 'showCloseButton' ) ) . toBe ( true ) ;
1481+ expect ( POM . popup . component . option ( 'enableBodyScroll' ) ) . toBe ( true ) ;
1482+ } ) ;
1483+
1484+ it ( 'should apply wrapperAttr configuration to popup' , async ( ) => {
1485+ const { scheduler, POM } = await createScheduler ( {
1486+ ...getDefaultConfig ( ) ,
1487+ editing : {
1488+ allowAdding : true ,
1489+ allowUpdating : true ,
1490+ popup : {
1491+ wrapperAttr : {
1492+ id : 'test' ,
1493+ } ,
1494+ } ,
1495+ } ,
1496+ } ) ;
1497+
1498+ scheduler . showAppointmentPopup ( commonAppointment ) ;
1499+
1500+ const wrapperAttr = POM . popup . component . option ( 'wrapperAttr' ) ;
1501+ expect ( wrapperAttr . id ) . toBe ( 'test' ) ;
1502+ expect ( wrapperAttr . class ) . toBeDefined ( ) ;
1503+ } ) ;
1504+
1505+ it ( 'should call onShowing callback when popup is shown' , async ( ) => {
1506+ const onShowing = jest . fn ( ) ;
1507+ const onAppointmentFormOpening = jest . fn ( ) ;
1508+ const { scheduler } = await createScheduler ( {
1509+ ...getDefaultConfig ( ) ,
1510+ editing : {
1511+ allowAdding : true ,
1512+ allowUpdating : true ,
1513+ popup : {
1514+ onShowing,
1515+ } ,
1516+ } ,
1517+ onAppointmentFormOpening,
1518+ } ) ;
1519+
1520+ scheduler . showAppointmentPopup ( commonAppointment ) ;
1521+
1522+ expect ( onShowing ) . toHaveBeenCalled ( ) ;
1523+ expect ( onShowing ) . toHaveBeenCalledTimes ( 1 ) ;
1524+ expect ( onAppointmentFormOpening ) . toHaveBeenCalled ( ) ;
1525+ expect ( onAppointmentFormOpening ) . toHaveBeenCalledTimes ( 1 ) ;
1526+ } ) ;
1527+
1528+ it ( 'should call onHiding callback when popup is hidden' , async ( ) => {
1529+ const onHiding = jest . fn ( ) ;
1530+ const { scheduler } = await createScheduler ( {
1531+ ...getDefaultConfig ( ) ,
1532+ editing : {
1533+ allowAdding : true ,
1534+ allowUpdating : true ,
1535+ popup : {
1536+ onHiding,
1537+ } ,
1538+ } ,
1539+ } ) ;
1540+
1541+ const focusSpy = jest . spyOn ( scheduler , 'focus' ) ;
1542+
1543+ scheduler . showAppointmentPopup ( commonAppointment ) ;
1544+
1545+ expect ( onHiding ) . not . toHaveBeenCalled ( ) ;
1546+ expect ( focusSpy ) . not . toHaveBeenCalled ( ) ;
1547+
1548+ scheduler . hideAppointmentPopup ( ) ;
1549+
1550+ expect ( onHiding ) . toHaveBeenCalled ( ) ;
1551+ expect ( onHiding ) . toHaveBeenCalledTimes ( 1 ) ;
1552+ expect ( focusSpy ) . toHaveBeenCalled ( ) ;
1553+ expect ( focusSpy ) . toHaveBeenCalledTimes ( 1 ) ;
1554+
1555+ focusSpy . mockRestore ( ) ;
1556+ } ) ;
1557+ } ) ;
14011558} ) ;
14021559
14031560describe ( 'Appointment Popup Content' , ( ) => {
0 commit comments