/
modal-window.spec.ts
50 lines (36 loc) · 1.61 KB
/
modal-window.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {NgbModalWindow} from './modal-window';
describe('ngb-modal-dialog', () => {
let fixture: ComponentFixture<NgbModalWindow>;
beforeEach(() => {
TestBed.configureTestingModule({declarations: [NgbModalWindow]});
fixture = TestBed.createComponent(NgbModalWindow);
});
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');
});
});
});