Skip to content

Commit

Permalink
Merge pull request #87 from jalussa-santos/ajustesStandardJs
Browse files Browse the repository at this point in the history
Refatoração com standardjs
  • Loading branch information
jalussa-santos authored Jul 26, 2021
2 parents 6a19ef7 + 6e260cf commit 5522bf0
Show file tree
Hide file tree
Showing 22 changed files with 456 additions and 465 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ npm test
* [Lendo o localStorage do navegador](https://github.com/jalussa-santos/cypress-example/issues/81)
* [Simulando um atraso na chamada à API](https://github.com/jalussa-santos/cypress-example/issues/83)
* [Validando requisições em cache](https://github.com/jalussa-santos/cypress-example/issues/85)
* [Análise de código e refatoração com standardjs](https://github.com/jalussa-santos/cypress-example/issues/88)


* **Teste de regressão visual**
Expand Down
70 changes: 35 additions & 35 deletions cypress/integration/exemploAvancado/hackerNewsSearch.spec.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
describe('Hacker News Search', () => {
const termo = 'cypress.io'
beforeEach(() => {
cy.intercept(
'**/search?query=redux&page=0&hitsPerPage=100',
{ fixture: 'empty'}
).as('empty')
cy.intercept(
const termo = 'cypress.io'

beforeEach(() => {
cy.intercept(
'**/search?query=redux&page=0&hitsPerPage=100',
{ fixture: 'empty' }
).as('empty')
cy.intercept(
`**/search?query=${termo}&page=0&hitsPerPage=100`,
{ fixture: 'stories'}
).as('stories')

cy.visit('https://infinite-savannah-93746.herokuapp.com/')
cy.wait('@empty')
})

it('armazena em cache os resultados corretamente', () => {
const faker = require('faker')
const palavraRandomica =faker.random.word()
let count = 0

cy.intercept(`**/search?query=${palavraRandomica}**`, req => {
count +=1
req.reply({fixture: 'empty'})
}).as('random')

{ fixture: 'stories' }
).as('stories')

cy.visit('https://infinite-savannah-93746.herokuapp.com/')
cy.wait('@empty')
})

it('armazena em cache os resultados corretamente', () => {
const faker = require('faker')
const palavraRandomica = faker.random.word()
let count = 0

cy.intercept(`**/search?query=${palavraRandomica}**`, req => {
count += 1
req.reply({ fixture: 'empty' })
}).as('random')

cy.search(palavraRandomica).then(() => {
expect(count, `network calls to fetch ${palavraRandomica}`).to.equal(1)

cy.wait('@random')

cy.search(termo)
cy.wait('@stories')

cy.search(palavraRandomica).then(() => {
expect(count, `network calls to fetch ${palavraRandomica}`).to.equal(1)

cy.wait('@random')

cy.search(termo)
cy.wait('@stories')

cy.search(palavraRandomica).then(() => {
expect(count, `network calls to fetch ${palavraRandomica}`).to.equal(1)
})
})
})
})
})
})
Loading

0 comments on commit 5522bf0

Please sign in to comment.