Skip to content

Commit

Permalink
refactor: refactor libs
Browse files Browse the repository at this point in the history
  • Loading branch information
GersonDantas committed Apr 16, 2022
1 parent 461fa92 commit 57b032b
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 77 deletions.
167 changes: 105 additions & 62 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/main/test/cypress/integration/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import * as Http from '../utils/http-mocks'

import faker from 'faker'

const path = /login/
const path = /api\/login/
const mockInvalidCredentialsError = (): void => Http.mockUnauthorizedError(path)
const mockUnexpectedError = (): void => Http.mockServerError(path, 'POST')
const mockSuccess = (): void => Http.mockOk(path, 'POST', 'account')
const mockSuccess = (): void => {
Http.mockOk(/api\/surveys/, 'GET', 'survey-list')
Http.mockOk(path, 'POST', 'account', 'loginRequest')
}

const populateField = (): void => {
cy.getByTestId('email').focus().type(faker.internet.email())
Expand Down Expand Up @@ -84,13 +87,13 @@ describe('Login', () => {
mockSuccess()
populateField()
cy.getByTestId('submit').dblclick()
cy.wait('@request')
Helpers.testHttpCallsCount(1)
cy.wait('@loginRequest')
cy.get('@loginRequest.all').should('have.length', 1)
})

it('Should not call submit if form is invalid', () => {
mockSuccess()
cy.getByTestId('email').focus().type(faker.internet.email()).type('{enter}')
Helpers.testHttpCallsCount(0)
cy.get('@loginRequest.all').should('have.length', 0)
})
})
Loading

0 comments on commit 57b032b

Please sign in to comment.