-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
113 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
import { AppComponent } from './app.component' | ||
import { ApuestasBindingComponent } from './apuestas-binding/apuestas-binding.component' | ||
import { ApuestasReactiveComponent } from './apuestas-reactive/apuestas-reactive.component' | ||
import { RouterModule } from '@angular/router' | ||
|
||
describe('AppComponent', () => { | ||
let component: AppComponent | ||
let fixture: ComponentFixture<AppComponent> | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AppComponent], | ||
}).compileComponents(); | ||
}); | ||
imports: [AppComponent, ApuestasBindingComponent, ApuestasReactiveComponent, RouterModule.forRoot([])], | ||
}).compileComponents() | ||
fixture = TestBed.createComponent(AppComponent) | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
it(`should have the 'eg-apuestas-angular' title`, () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app.title).toEqual('eg-apuestas-angular'); | ||
}); | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
it('should render title', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, eg-apuestas-angular'); | ||
}); | ||
}); | ||
it('should render two options', () => { | ||
const compiled = fixture.nativeElement as HTMLElement | ||
expect(compiled.querySelectorAll('li').length).toBe(2) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/apuestas-binding/validationField/validationField.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/app/apuestas-binding/apuesta.ts → src/app/domain/apuesta.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
7 changes: 3 additions & 4 deletions
7
src/app/apuestas-binding/test-utils.ts → src/utils/test-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import { AppComponent } from './app.component' | ||
import { ComponentFixture } from '@angular/core/testing' | ||
|
||
export const getByTestId = (appComponent: ComponentFixture<AppComponent>, testId: string) => { | ||
export const getByTestId = (appComponent: ComponentFixture<unknown>, testId: string) => { | ||
const compiled = appComponent.debugElement.nativeElement | ||
return compiled.querySelector(`[data-testid="${testId}"]`) | ||
} | ||
|
||
export const mensajeDeError = (fixture: ComponentFixture<AppComponent>, field: string) => { | ||
export const mensajeDeError = (fixture: ComponentFixture<unknown>, field: string) => { | ||
return getByTestId(fixture, `errorMessage-${field}`).textContent | ||
} | ||
|
||
export const resultado = (fixture: ComponentFixture<AppComponent>) => { | ||
export const resultado = (fixture: ComponentFixture<unknown>) => { | ||
return getByTestId(fixture, 'resultado').textContent | ||
} |