diff --git a/src/async-tokenize/async-tokenize.test.ts b/src/async-tokenize/async-tokenize.test.ts index e182a36..f80b445 100644 --- a/src/async-tokenize/async-tokenize.test.ts +++ b/src/async-tokenize/async-tokenize.test.ts @@ -1,12 +1,9 @@ import { fireEvent, waitFor } from '@testing-library/dom' import { AsyncTokenize } from './async-tokenize' -import * as utilsValues from 'src/common/utils/form-values/form-values' -import * as utilsElements from 'src/common/utils/form-elements/form-elements' import { configureFormSubmissionMock, formElementsMock, - formValuesMock, malgaConfigurations, } from 'tests/mocks/common-configurations' import { generateForm } from 'tests/mocks/form-dom' @@ -117,40 +114,6 @@ describe('async-tokenize', () => { expect(inputs.length).toBe(1) }) }) - test('should be possible for handle to call the getFormElements, getFormValues, Tokenization, removeFormElements and createFormElements functions passing the elements correctly', async () => { - configureFormSubmissionMock() - - generateForm(onSubmit) - - const malga = new Malga(malgaConfigurations(false)) - - const asyncTokenizeObject = new AsyncTokenize(malga, formElementsMock) - - const getFormElementsSpy = vi.spyOn(utilsElements, 'getFormElements') - const getFormValuesSpy = vi.spyOn(utilsValues, 'getFormValues') - const tokenizationSpy = vi.spyOn(malga, 'tokenization') - const removeFormElementsSpy = vi.spyOn(utilsElements, 'removeFormElements') - const createFormElementSpy = vi.spyOn(utilsElements, 'createFormElement') - - asyncTokenizeObject.handle() - - const form = document.querySelector('form') - fireEvent.submit(form!) - - await waitFor(() => { - const tokenIdInput = document.querySelector( - 'input[name="tokenId"]', - ) - expect(getFormElementsSpy).toHaveBeenCalledWith(formElementsMock) - expect(getFormValuesSpy).toHaveBeenCalledWith(formElementsMock) - expect(tokenizationSpy).toHaveBeenCalledWith(formValuesMock) - expect(removeFormElementsSpy).toHaveBeenCalledWith(formElementsMock) - expect(createFormElementSpy).toHaveBeenCalledWith( - tokenIdInput?.name, - tokenIdInput?.value, - ) - }) - }) test('should be possible to return an error if empty apiKey and clientId are sent to the Malga constructor', async () => { configureFormSubmissionMock()