This commit is contained in:
2025-01-01 23:45:40 +01:00
parent 14cdc06de5
commit 20ba36c052
3 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
describe('FilterPokemonPipe', () => {
beforeEach(() => {
cy.visit('http://localhost:4200')
})
it('should test search', () => {
/* class using . */
cy.get('.filter_pokedex').clear()
cy.get('.filter_pokedex').type('charm')
cy.get('.select_pokedex').select(1)
cy.get('button').contains('GO').click()
cy.get('.pokemon').should('be.visible')
})
it('should use combo box', () => {
cy.get('.select_pokedex').select(0)
cy.get('button').contains('GO').click()
cy.get('.pokemon').should('be.visible')
})
it('should navigate to previous pokemon', () => {
cy.get('.select_pokedex').select(1)
cy.get('button').contains('GO').click()
})
})

View File

@@ -0,0 +1,21 @@
describe('Pokemon API Tests', () => {
beforeEach(() => {
cy.visit('http://localhost:4200')
})
it('should get the database', () => {
/*https://docs.cypress.io/api/commands/request*/
cy.request('GET', 'https://pokeapi.co/api/v2/pokemon')
.then((response) => {
// 200 = OK
expect(response.status).to.eq(200)
const pokeData = response.body
expect(pokeData).to.have.property('count')
expect(pokeData.count).to.be.a('number')
expect(pokeData.next).to.be.a('string')
expect(pokeData.results[0]).to.have.property('name')
expect(pokeData.results[0].name).to.eq('bulbasaur')
})
})
})

View File

@@ -39,6 +39,6 @@ describe('AppComponent', () => {
it('should render the title', () => {
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('pokedemo');
expect(compiled.querySelector('h1')?.textContent).toContain('pokedemo!');
});
});