feat(challenge20): setup test for challenge

This commit is contained in:
thomas
2023-04-25 14:46:38 +02:00
parent f378ea01fb
commit 8ce516adc2
3 changed files with 32 additions and 29 deletions

View File

@@ -0,0 +1,19 @@
import { AppComponent } from './app.component';
describe(AppComponent.name, () => {
const setup = () => {
cy.mount(AppComponent);
};
test('error modal is displayed if you click on "Confirm" without inputing a name', () => {
setup();
});
test('error message is shown if you click "Cancel" in the confirmation modal after submitting a name', () => {
setup();
});
test('confirm message is shown if you click "Confirm" in the confirmation modal after submitting a name', () => {
setup();
});
});

View File

@@ -1,32 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { render } from '@testing-library/angular';
import { AppComponent } from './app.component';
import { NxWelcomeComponent } from './nx-welcome.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppComponent, NxWelcomeComponent],
}).compileComponents();
test('error modal is displayed if you click on "Confirm" without inputing a name', async () => {
await render(AppComponent);
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
test('error message is shown if you click "Cancel" in the confirmation modal after submitting a name', async () => {
await render(AppComponent);
});
it(`should have as title 'testing-modal'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('testing-modal');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain(
'Welcome testing-modal'
);
test('confirm message is shown if you click "Confirm" in the confirmation modal after submitting a name', async () => {
await render(AppComponent);
});
});