Skip to content

Commit

Permalink
feat(payment): PAYPAL-4995 added check for teardown call in deinitial…
Browse files Browse the repository at this point in the history
…ize method
  • Loading branch information
bc-nick committed Jan 8, 2025
1 parent e050766 commit 1e16475
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ describe('BraintreeHostedForm', () => {

expect(cardFields.teardown).toHaveBeenCalled();
});

it('do not call teardown if fields are not initialized', async () => {
await subject.initialize({
...formOptions,
fields: {},
});
await subject.deinitialize();

expect(cardFields.teardown).not.toHaveBeenCalled();
});
});

describe('#tokenize', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ export default class BraintreeHostedForm {
}

async deinitialize(): Promise<void> {
this._isInitializedHostedForm = false;
if (this._isInitializedHostedForm) {
this._isInitializedHostedForm = false;

await this._cardFields?.teardown();
await this._cardFields?.teardown();
}
}

validate() {
Expand Down

0 comments on commit 1e16475

Please sign in to comment.