cypress
This commit is contained in:
25
cypress/e2e/Pokedemo/filter-pokemon.cy.js
Normal file
25
cypress/e2e/Pokedemo/filter-pokemon.cy.js
Normal 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()
|
||||||
|
})
|
||||||
|
})
|
||||||
21
cypress/e2e/Pokedemo/pokemon.cy.js
Normal file
21
cypress/e2e/Pokedemo/pokemon.cy.js
Normal 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')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
@@ -39,6 +39,6 @@ describe('AppComponent', () => {
|
|||||||
|
|
||||||
it('should render the title', () => {
|
it('should render the title', () => {
|
||||||
const compiled = fixture.nativeElement as HTMLElement;
|
const compiled = fixture.nativeElement as HTMLElement;
|
||||||
expect(compiled.querySelector('h1')?.textContent).toContain('pokedemo');
|
expect(compiled.querySelector('h1')?.textContent).toContain('pokedemo!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user