-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
292e136
commit 403ca3b
Showing
10 changed files
with
1,393 additions
and
103 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
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 |
---|---|---|
|
@@ -71,3 +71,4 @@ package/ | |
|
||
website/ | ||
dist/ | ||
/cypress/downloads/ |
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
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
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,23 +1,40 @@ | ||
import { elements } from './helpers/elements' | ||
import { validate as validadeCpf } from '../../packages/gerador-validador-cpf' | ||
|
||
describe('generate', async () => { | ||
it('should generate only valid cpfs', () => { | ||
cy.visit('/') | ||
const generateCpf = () => { | ||
cy.visit('/') | ||
|
||
cy.get(elements.inputGenerateCpf) | ||
.invoke('val') | ||
.should(($cpf) => { | ||
// @ts-expect-error: Accepts string | ||
expect(validadeCpf($cpf)).to.equal(true) | ||
}) | ||
|
||
cy.get(elements.inputGenerateCpf) | ||
.invoke('val') | ||
.should(($cpf) => { | ||
// @ts-expect-error: Accepts string | ||
expect(validadeCpf($cpf)).to.equal(true) | ||
}) | ||
cy.get(elements.generateCpfButton).click() | ||
cy.get(elements.inputGenerateCpf) | ||
.invoke('val') | ||
.should(($cpf) => { | ||
// @ts-expect-error: Accepts string | ||
expect(validadeCpf($cpf)).to.equal(true) | ||
}) | ||
} | ||
|
||
cy.get(elements.generateCpfButton).click() | ||
cy.get(elements.inputGenerateCpf) | ||
.invoke('val') | ||
.should(($cpf) => { | ||
// @ts-expect-error: Accepts string | ||
expect(validadeCpf($cpf)).to.equal(true) | ||
}) | ||
describe('generate (desktop)', () => { | ||
it('should generate only valid cpfs', () => { | ||
generateCpf() | ||
}) | ||
}) | ||
|
||
describe( | ||
'generate (mobile)', | ||
{ | ||
viewportHeight: 1000, | ||
viewportWidth: 400, | ||
}, | ||
() => { | ||
it('should generate only valid cpfs', () => { | ||
generateCpf() | ||
}) | ||
}, | ||
) |
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,57 +1,91 @@ | ||
import { elements } from './helpers/elements' | ||
|
||
describe('validate', () => { | ||
it('inserting a cpf missing digits should return a incomplete message', () => { | ||
cy.visit('/') | ||
cy.get(elements.validateMessage).should('have.text', '...') | ||
|
||
cy.get(elements.enLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).type('137.686.36-63') | ||
cy.get(elements.validateMessage).should('have.text', 'incomplete') | ||
|
||
cy.get(elements.ptLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('50.016.460-88') | ||
cy.get(elements.validateMessage).should('have.text', 'incompleto') | ||
|
||
cy.get(elements.esLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('740846005') | ||
cy.get(elements.validateMessage).should('have.text', 'incompleto') | ||
}) | ||
const incompleteCpf = () => { | ||
cy.visit('/') | ||
cy.get(elements.validateMessage).should('have.text', '...') | ||
|
||
it('inserting a valid CPF should return a valid message', () => { | ||
cy.visit('/') | ||
cy.get(elements.enLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).type('137.686.36-63') | ||
cy.get(elements.validateMessage).should('have.text', 'incomplete') | ||
|
||
cy.get(elements.enLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).type('137.686.636-63') | ||
cy.get(elements.validateMessage).should('have.text', 'Valid CPF') | ||
cy.get(elements.ptLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('50.016.460-88') | ||
cy.get(elements.validateMessage).should('have.text', 'incompleto') | ||
|
||
cy.get(elements.ptLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('506.016.460-88') | ||
cy.get(elements.validateMessage).should('have.text', 'CPF Válido') | ||
cy.get(elements.esLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('740846005') | ||
cy.get(elements.validateMessage).should('have.text', 'incompleto') | ||
} | ||
|
||
cy.get(elements.esLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('74082746005') | ||
cy.get(elements.validateMessage).should('have.text', 'CPF Válido') | ||
}) | ||
it('inserting a invalid CPF should return a invalid message', () => { | ||
cy.visit('/') | ||
const validCpf = () => { | ||
cy.visit('/') | ||
|
||
cy.get(elements.enLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).type('137.686.636-63') | ||
cy.get(elements.validateMessage).should('have.text', 'Valid CPF') | ||
|
||
cy.get(elements.ptLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('506.016.460-88') | ||
cy.get(elements.validateMessage).should('have.text', 'CPF Válido') | ||
|
||
cy.get(elements.esLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('74082746005') | ||
cy.get(elements.validateMessage).should('have.text', 'CPF Válido') | ||
} | ||
|
||
const invalidCpf = () => { | ||
cy.visit('/') | ||
|
||
cy.get(elements.enLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).type('137.986.656-63') | ||
cy.get(elements.validateMessage).should('have.text', 'Invalid CPF') | ||
|
||
cy.get(elements.enLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).type('137.986.656-63') | ||
cy.get(elements.validateMessage).should('have.text', 'Invalid CPF') | ||
cy.get(elements.ptLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('11111111111') | ||
cy.get(elements.validateMessage).should('have.text', 'CPF Inválido') | ||
|
||
cy.get(elements.ptLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('11111111111') | ||
cy.get(elements.validateMessage).should('have.text', 'CPF Inválido') | ||
cy.get(elements.esLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('96783567825') | ||
cy.get(elements.validateMessage).should('have.text', 'CPF no válido') | ||
} | ||
|
||
cy.get(elements.esLocaleButton).click() | ||
cy.get(elements.inputValidateCpf).clear() | ||
cy.get(elements.inputValidateCpf).type('96783567825') | ||
cy.get(elements.validateMessage).should('have.text', 'CPF no válido') | ||
describe('validate (desktop)', () => { | ||
it('inserting a cpf missing digits should return a incomplete message', () => { | ||
incompleteCpf() | ||
}) | ||
|
||
it('inserting a valid CPF should return a valid message', () => { | ||
validCpf() | ||
}) | ||
|
||
it('inserting a invalid CPF should return a invalid message', () => { | ||
invalidCpf() | ||
}) | ||
}) | ||
|
||
describe( | ||
'validate (mobile)', | ||
{ | ||
viewportHeight: 1000, | ||
viewportWidth: 400, | ||
}, | ||
() => { | ||
it('inserting a cpf missing digits should return a incomplete message', () => { | ||
incompleteCpf() | ||
}) | ||
|
||
it('inserting a valid CPF should return a valid message', () => { | ||
validCpf() | ||
}) | ||
|
||
it('inserting a invalid CPF should return a invalid message', () => { | ||
invalidCpf() | ||
}) | ||
}, | ||
) |
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
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
Oops, something went wrong.