@@ -26,7 +26,8 @@ describe('Dialog', () => {
2626 CustomTemplates1DialogComponent ,
2727 CustomTemplates2DialogComponent ,
2828 DialogSampleComponent ,
29- PositionSettingsDialogComponent
29+ PositionSettingsDialogComponent ,
30+ DialogTwoWayDataBindingComponent
3031 ] ,
3132 imports : [ BrowserAnimationsModule , NoopAnimationsModule , IgxDialogModule ]
3233 } ) . compileComponents ( ) ;
@@ -80,17 +81,40 @@ describe('Dialog', () => {
8081 expect ( messageDebugElement . nativeElement . textContent . trim ( ) ) . toEqual ( expectedMessage ) ;
8182 } ) ;
8283
83- it ( 'Should open dialog when opened property is set to true ' , ( ) => {
84+ it ( 'Should open and close dialog when set values to IsOpen ' , fakeAsync ( ( ) => {
8485 const fixture = TestBed . createComponent ( AlertComponent ) ;
8586 const dialog = fixture . componentInstance . dialog ;
8687 const expectedMessage = 'message' ;
8788
88- dialog . opened = true ;
89+ dialog . isOpen = true ;
90+ tick ( ) ;
8991 fixture . detectChanges ( ) ;
92+ expect ( dialog . isOpen ) . toEqual ( true ) ;
9093
91- const messageDebugElement = fixture . debugElement . query ( By . css ( '.igx-dialog__window-content' ) ) ;
92- expect ( messageDebugElement . nativeElement . textContent . trim ( ) ) . toEqual ( expectedMessage ) ;
93- } ) ;
94+ dialog . close ( ) ;
95+ tick ( ) ;
96+ fixture . detectChanges ( ) ;
97+ expect ( dialog . isOpen ) . toEqual ( false ) ;
98+ } ) ) ;
99+
100+ it ( 'Should open and close dialog with isOpen two way data binding' , fakeAsync ( ( ) => {
101+ const fixture = TestBed . createComponent ( DialogTwoWayDataBindingComponent ) ;
102+ const dialog = fixture . componentInstance . dialog ;
103+ fixture . detectChanges ( ) ;
104+
105+ fixture . componentInstance . myDialog = true ;
106+
107+ fixture . detectChanges ( ) ;
108+ tick ( ) ;
109+ expect ( dialog . isOpen ) . toEqual ( true ) ;
110+
111+
112+ fixture . componentInstance . myDialog = false ;
113+
114+ fixture . detectChanges ( ) ;
115+ tick ( ) ;
116+ expect ( dialog . isOpen ) . toEqual ( false ) ;
117+ } ) ) ;
94118
95119 it ( 'Should set custom modal message.' , ( ) => {
96120 const fixture = TestBed . createComponent ( CustomDialogComponent ) ;
@@ -322,6 +346,7 @@ describe('Dialog', () => {
322346 dialog . open ( ) ;
323347 tick ( 100 ) ;
324348 fix . detectChanges ( ) ;
349+ tick ( 100 ) ;
325350
326351 // Verify dialog is opened and its default right button is focused
327352 const dialogDOM = fix . debugElement . query ( By . css ( '.igx-dialog' ) ) ;
@@ -448,6 +473,28 @@ class AlertComponent {
448473class DialogComponent {
449474 @ViewChild ( 'dialog' , { static : true } ) public dialog : IgxDialogComponent ;
450475}
476+
477+ @Component ( {
478+ template : `<div #wrapper>
479+ <igx-dialog #dialog title="dialog" message="message"
480+ [(isOpen)]="myDialog"
481+ leftButtonLabel="left button"
482+ leftButtonType="raised"
483+ leftButtonColor="black"
484+ leftButtonBackgroundColor="darkblue"
485+ leftButtonRipple="pink"
486+ rightButtonLabel="right button"
487+ rightButtonType="raised"
488+ rightButtonColor="orange"
489+ rightButtonBackgroundColor="lightblue"
490+ rightButtonRipple="white">
491+ </igx-dialog>
492+ </div>` } )
493+ class DialogTwoWayDataBindingComponent {
494+ @ViewChild ( 'dialog' , { static : true } ) public dialog : IgxDialogComponent ;
495+ public myDialog = false ;
496+ }
497+
451498@Component ( {
452499 template : `<div #wrapper>
453500 <igx-dialog #dialog
0 commit comments