mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Add test for checkout handler component
This commit is contained in:
parent
986918f86b
commit
d3cad1105a
3 changed files with 26 additions and 1 deletions
|
@ -1,8 +1,9 @@
|
|||
import {render, screen} from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import '@testing-library/jest-dom';
|
||||
import {CheckoutHandler} from "../Components/checkout-handler";
|
||||
|
||||
test('checkout handler label display given text', async () => {
|
||||
test('checkbox label displays the given text', async () => {
|
||||
render(
|
||||
<CheckoutHandler
|
||||
getCardFieldsForm={() => {}}
|
||||
|
@ -13,3 +14,21 @@ test('checkout handler label display given text', async () => {
|
|||
|
||||
await expect(screen.getByLabelText('Foo')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('click checkbox calls function passing checked value', async () => {
|
||||
const getSavePayment = jest.fn();
|
||||
|
||||
render(
|
||||
<CheckoutHandler
|
||||
getSavePayment={getSavePayment}
|
||||
getCardFieldsForm={() => {}}
|
||||
saveCardText="Foo"
|
||||
is_vaulting_enabled={true}
|
||||
/>
|
||||
);
|
||||
|
||||
await userEvent.click(screen.getByLabelText('Foo'));
|
||||
|
||||
await expect(getSavePayment.mock.calls).toHaveLength(1);
|
||||
await expect(getSavePayment.mock.calls[0][0]).toBe(true);
|
||||
});
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
"@testing-library/dom": "^10.1.0",
|
||||
"@testing-library/jest-dom": "^6.4.6",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@testing-library/user-event": "^14.5.2",
|
||||
"@wordpress/element": "^6.1.0",
|
||||
"@wordpress/scripts": "^28.0.0",
|
||||
"babel-plugin-explicit-exports-references": "^1.0.2",
|
||||
|
|
|
@ -1748,6 +1748,11 @@
|
|||
dependencies:
|
||||
"@babel/runtime" "^7.12.5"
|
||||
|
||||
"@testing-library/user-event@^14.5.2":
|
||||
version "14.5.2"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.5.2.tgz#db7257d727c891905947bd1c1a99da20e03c2ebd"
|
||||
integrity sha512-YAh82Wh4TIrxYLmfGcixwD18oIjyC1pFQC2Y01F2lzV2HTMiYrI0nze0FD0ocB//CKS/7jIUgae+adPqxK5yCQ==
|
||||
|
||||
"@tootallnate/once@2":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue