mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-11 21:33:02 -05:00
feat(challenge20): setup test for challenge
This commit is contained in:
19
apps/testing-modal/src/app/app.component.cy.ts
Normal file
19
apps/testing-modal/src/app/app.component.cy.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user