Skip to content

Commit 7359f52

Browse files
committed
au-tab-panel tests
1 parent e44be40 commit 7359f52

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

au-modal/src/app/app.component.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,24 @@ <h5>{{title}}</h5>
7777
</au-modal>
7878

7979

80+
<au-modal id="testModal" *auModalOpenOnClick="testButton">
81+
82+
<form>
83+
<label>Email:</label><input placeholder="Email" type="email">
84+
</form>
85+
86+
87+
</au-modal>
88+
8089

8190
<div class="modal-buttons">
8291

8392
<button #loginButton>Login</button>
8493

8594
<button #signUpButton>Sign Up</button>
8695

96+
<button #testButton id="testButton">Test Modal</button>
97+
8798
</div>
8899

89100
</div>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import {TestBed, async} from '@angular/core/testing';
2+
import {ComponentFixture} from '@angular/core/testing';
3+
import {DebugElement} from '@angular/core';
4+
import {By} from '@angular/platform-browser';
5+
import {AppComponent} from './app.component';
6+
import {AuModalOpenOnClickDirective} from "./au-modal/au-modal-open-on-click.directive";
7+
import {AuModalComponent} from "./au-modal/au-modal.component";
8+
import {AuInputModule} from "au-input";
9+
import {AuTabPanelModule} from "au-tab-panel";
10+
import {AuModalModule} from "./au-modal/au-modal.module";
11+
12+
13+
14+
describe('AppComponent', () => {
15+
16+
let component: AppComponent,
17+
fixture: ComponentFixture<AppComponent>,
18+
el: DebugElement,
19+
modal: DebugElement;
20+
21+
22+
beforeEach(async(() => {
23+
TestBed.configureTestingModule({
24+
declarations: [
25+
AppComponent
26+
],
27+
imports: [
28+
AuInputModule,
29+
AuTabPanelModule,
30+
AuModalModule.forRoot()
31+
]
32+
33+
}).compileComponents();
34+
}));
35+
36+
beforeEach(() => {
37+
38+
fixture = TestBed.createComponent(AppComponent);
39+
component = fixture.debugElement.componentInstance;
40+
el = fixture.debugElement;
41+
modal = el.query(By.css('#testModal'));
42+
43+
fixture.detectChanges();
44+
45+
});
46+
47+
48+
it('should create the test application', async(() => {
49+
50+
expect(component).toBeTruthy();
51+
52+
}));
53+
54+
55+
it('should not add the modal to the page, if the modal is closed', async(() => {
56+
57+
expect(modal).toBeFalsy();
58+
59+
}));
60+
61+
62+
it('should open the modal when the test button is clicked', async(() => {
63+
64+
fixture.nativeElement.querySelector("#testButton").click();
65+
66+
fixture.detectChanges();
67+
68+
const openedModal = fixture.nativeElement.querySelector("#testModal");
69+
70+
71+
expect(openedModal).toBeTruthy();
72+
73+
}));
74+
75+
76+
});

0 commit comments

Comments
 (0)