-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from jalussa-santos/ajustesStandardJs
Refatoração com standardjs
- Loading branch information
Showing
22 changed files
with
456 additions
and
465 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
70 changes: 35 additions & 35 deletions
70
cypress/integration/exemploAvancado/hackerNewsSearch.spec.js
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,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) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.