Skip to content

Commit

Permalink
refactor: changes to returned error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
milenacrios committed Mar 5, 2024
1 parent 3cad06c commit d5f7771
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/async-tokenize/tests/async-tokenize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ describe('handle', () => {

const asyncTokenizeObject = new AsyncTokenize(malga, formElementsMock)

expect(asyncTokenizeObject.handle).toThrowError()
expect(asyncTokenizeObject.handle).toThrowError(
"Cannot read properties of undefined (reading 'elements')",
)

const form = document.querySelector('form')
fireEvent.submit(form!)
Expand Down
2 changes: 1 addition & 1 deletion src/common/malga/malga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Malga', () => {
cvv: '951',
expirationDate: '05/2030',
})
console.log('response: ', response)

expect(response).toMatchObject({ tokenId: 'sandbox-token-id' })
})

Expand Down
10 changes: 5 additions & 5 deletions src/common/utils/tests/form-elements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
removeFormElements,
} from '../form-elements/form-elements'

function Form() {
function generateForm() {
const { form, holderNameInput, cvvInput, expirationDateInput, numberInput } =
handleFormMock()

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('getFormElements', () => {
})

test('should be possible to find the elements in the dom', () => {
Form()
generateForm()

const formElements = getFormElements({
form: 'data-malga-tokenization-form',
Expand All @@ -83,7 +83,7 @@ describe('getFormElements', () => {
})

test("Should be returned null when elements aren't finded", () => {
Form()
generateForm()

const formElements = getFormElements({
form: 'data-malga-form',
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('removeFormElements', () => {
document.body.innerHTML = ''
})
test('should be possible to return null when trying to find the elements in the dom after calling the function', () => {
Form()
generateForm()

removeFormElements({
form: 'data-malga-tokenization-form',
Expand All @@ -140,7 +140,7 @@ describe('removeFormElements', () => {
expect(document.querySelector('data-malga-tokenization-cvv')).toBeNull()
})
test('should be returned the elements in the DOM, when the function are called with selectores wrong, since the elements could not be removed', () => {
Form()
generateForm()

removeFormElements({
form: 'data-malga-form',
Expand Down
4 changes: 3 additions & 1 deletion src/tokenize/tests/tokenize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ describe('handle', () => {

const tokenizeObject = new Tokenize(malga, formElementsMock)

await expect(tokenizeObject.handle).rejects.toThrowError()
await expect(tokenizeObject.handle).rejects.toThrowError(
"Cannot read properties of undefined (reading 'elements')",
)
})
test('should be possible to perform the tokenization function and getFormValues with the respective elements correctly', async () => {
generateForm()
Expand Down

0 comments on commit d5f7771

Please sign in to comment.