From a52d50e788792a63e97a9176ab319d53db7a2853 Mon Sep 17 00:00:00 2001 From: vempo Date: Tue, 24 Jul 2018 17:34:04 +0300 Subject: Replaced old implementation at root Old project files and directories has been moved under 'deprecated-workflow-designer'. The old project is not built by the CI anymore, but can be still built manually. New modules/directories have been moved up and integrated with the CI system. Change-Id: I1528c792bcbcce9e50bfc294a1328a20e72c91cf Issue-ID: SDC-1559 Signed-off-by: vempo --- .../src/app/paletx/plx-modal/modal-window.spec.ts | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/plx-modal/modal-window.spec.ts (limited to 'deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/plx-modal/modal-window.spec.ts') diff --git a/deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/plx-modal/modal-window.spec.ts b/deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/plx-modal/modal-window.spec.ts new file mode 100644 index 00000000..5767bfee --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/plx-modal/modal-window.spec.ts @@ -0,0 +1,114 @@ +import {TestBed, ComponentFixture} from '@angular/core/testing'; + +import {PlxModalWindow} from './modal-window'; +import {ModalDismissReasons} from './modal-dismiss-reasons'; + +describe('plx-modal-dialog', () => { + + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({declarations: [PlxModalWindow]}); + fixture = TestBed.createComponent(PlxModalWindow); + }); + + describe('basic rendering functionality', () => { + + it('should render default modal window', () => { + fixture.detectChanges(); + + const modalEl: Element = fixture.nativeElement; + const dialogEl: Element = fixture.nativeElement.querySelector('.modal-dialog'); + + expect(modalEl).toHaveCssClass('modal'); + expect(dialogEl).toHaveCssClass('modal-dialog'); + }); + + it('should render default modal window with a specified size', () => { + fixture.componentInstance.size = 'sm'; + fixture.detectChanges(); + + const dialogEl: Element = fixture.nativeElement.querySelector('.modal-dialog'); + expect(dialogEl).toHaveCssClass('modal-dialog'); + expect(dialogEl).toHaveCssClass('modal-sm'); + }); + + it('should render default modal window with a specified class', () => { + fixture.componentInstance.windowClass = 'custom-class'; + fixture.detectChanges(); + + expect(fixture.nativeElement).toHaveCssClass('custom-class'); + }); + + it('aria attributes', () => { + fixture.detectChanges(); + const dialogEl: Element = fixture.nativeElement.querySelector('.modal-dialog'); + + expect(fixture.nativeElement.getAttribute('role')).toBe('dialog'); + expect(dialogEl.getAttribute('role')).toBe('document'); + }); + }); + + describe('dismiss', () => { + + it('should dismiss on backdrop click by default', (done) => { + fixture.detectChanges(); + + fixture.componentInstance.dismissEvent.subscribe(($event) => { + expect($event).toBe(ModalDismissReasons.BACKDROP_CLICK); + done(); + }); + + fixture.nativeElement.click(); + }); + + it('should not dismiss on modal content click when there is active backdrop', (done) => { + fixture.detectChanges(); + fixture.componentInstance.dismissEvent.subscribe( + () => { + done.fail(new Error('Should not trigger dismiss event')); + }); + + fixture.nativeElement.querySelector('.modal-content').click(); + setTimeout(done, 200); + }); + + it('should ignore backdrop clicks when there is no backdrop', (done) => { + fixture.componentInstance.backdrop = false; + fixture.detectChanges(); + + fixture.componentInstance.dismissEvent.subscribe(($event) => { + expect($event).toBe(ModalDismissReasons.BACKDROP_CLICK); + done.fail(new Error('Should not trigger dismiss event')); + }); + + fixture.nativeElement.querySelector('.modal-dialog').click(); + setTimeout(done, 200); + }); + + it('should ignore backdrop clicks when backdrop is "static"', (done) => { + fixture.componentInstance.backdrop = 'static'; + fixture.detectChanges(); + + fixture.componentInstance.dismissEvent.subscribe(($event) => { + expect($event).toBe(ModalDismissReasons.BACKDROP_CLICK); + done.fail(new Error('Should not trigger dismiss event')); + }); + + fixture.nativeElement.querySelector('.modal-dialog').click(); + setTimeout(done, 200); + }); + + it('should dismiss on esc press by default', (done) => { + fixture.detectChanges(); + + fixture.componentInstance.dismissEvent.subscribe(($event) => { + expect($event).toBe(ModalDismissReasons.ESC); + done(); + }); + + fixture.debugElement.triggerEventHandler('keyup.esc', {}); + }); + }); + +}); -- cgit 1.2.3-korg