Add react testing library

This commit is contained in:
Emili Castells Guasch 2024-06-22 12:32:36 +02:00
parent 7fd0d2e431
commit b68e0a6eb5
4 changed files with 84 additions and 3 deletions

View file

@ -1,6 +1,6 @@
const config = wc.wcSettings.getSetting('ppcp-credit-card-gateway_data');
export async function createOrder() {
const config = wc.wcSettings.getSetting('ppcp-credit-card-gateway_data');
return fetch(config.scriptData.ajax.create_order.endpoint, {
method: "POST",
headers: {
@ -23,6 +23,8 @@ export async function createOrder() {
}
export async function onApprove(data) {
const config = wc.wcSettings.getSetting('ppcp-credit-card-gateway_data');
return fetch(config.scriptData.ajax.approve_order.endpoint, {
method: "POST",
headers: {

View file

@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom'
import {CardFields} from "../Components/card-fields";
test('card fields component', () => {
render(<CardFields />);
});

View file

@ -101,7 +101,10 @@
"devDependencies": {
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@wordpress/element": "^6.1.0",
"@wordpress/scripts": "^28.0.0",
"jquery": "^3.7.1"
"jquery": "^3.7.1",
"react-dom": "^18.3.1"
}
}

View file

@ -1733,6 +1733,13 @@
lodash "^4.17.21"
redent "^3.0.0"
"@testing-library/react@^16.0.0":
version "16.0.0"
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-16.0.0.tgz#0a1e0c7a3de25841c3591b8cb7fb0cf0c0a27321"
integrity sha512-guuxUKRWQ+FgNX0h0NS0FIq3Q3uLtWVpBzcLOggmfMoUpgBnzBzvLLd4fbm6yS8ydJd94cIfY4yP9qUQjM2KwQ==
dependencies:
"@babel/runtime" "^7.12.5"
"@tootallnate/once@2":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
@ -1961,6 +1968,11 @@
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239"
integrity sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==
"@types/prop-types@*":
version "15.7.12"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
integrity sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==
"@types/qs@*":
version "6.9.15"
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.15.tgz#adde8a060ec9c305a82de1babc1056e73bd64dce"
@ -1971,6 +1983,21 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==
"@types/react-dom@^18.2.25":
version "18.3.0"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.3.0.tgz#0cbc818755d87066ab6ca74fbedb2547d74a82b0"
integrity sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==
dependencies:
"@types/react" "*"
"@types/react@*", "@types/react@^18.2.79":
version "18.3.3"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.3.tgz#9679020895318b0915d7a3ab004d92d33375c45f"
integrity sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==
dependencies:
"@types/prop-types" "*"
csstype "^3.0.2"
"@types/retry@0.12.0":
version "0.12.0"
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d"
@ -2419,6 +2446,27 @@
mime "^3.0.0"
web-vitals "^3.5.0"
"@wordpress/element@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@wordpress/element/-/element-6.1.0.tgz#3f6decc73b22095f795e71997ad54f7cab466599"
integrity sha512-DqAGqal1i6gTfYxz95zHnckbweS43MroHqMcz/Rww60pysTCoaRG5KZ/v4/3hry1tNCem1WQguY4ZMTF0MMTBQ==
dependencies:
"@babel/runtime" "^7.16.0"
"@types/react" "^18.2.79"
"@types/react-dom" "^18.2.25"
"@wordpress/escape-html" "^3.1.0"
change-case "^4.1.2"
is-plain-object "^5.0.0"
react "^18.3.0"
react-dom "^18.3.0"
"@wordpress/escape-html@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@wordpress/escape-html/-/escape-html-3.1.0.tgz#b119e6ef9b3bca59ce48e1d1eafe82269415d231"
integrity sha512-wcRGrGuGV4kTd5hJMXy/bdjCObqcwqFmd/HkDAUi2pfngEsv2aJhAeTfkGP5NwmY/F03Oqz2Qgd4UzTiIu2bjQ==
dependencies:
"@babel/runtime" "^7.16.0"
"@wordpress/eslint-plugin@^19.1.0":
version "19.1.0"
resolved "https://registry.yarnpkg.com/@wordpress/eslint-plugin/-/eslint-plugin-19.1.0.tgz#e0f2211febe3bf4832d585b2e9aeab7b6fe3cb30"
@ -3894,6 +3942,11 @@ cssstyle@^2.3.0:
dependencies:
cssom "~0.3.6"
csstype@^3.0.2:
version "3.1.3"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81"
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==
cwd@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/cwd/-/cwd-0.10.0.tgz#172400694057c22a13b0cf16162c7e4b7a7fe567"
@ -8305,6 +8358,14 @@ raw-body@2.5.2:
iconv-lite "0.4.24"
unpipe "1.0.0"
react-dom@^18.3.0, react-dom@^18.3.1:
version "18.3.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.3.1.tgz#c2265d79511b57d479b3dd3fdfa51536494c5cb4"
integrity sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==
dependencies:
loose-envify "^1.1.0"
scheduler "^0.23.2"
react-is@^16.13.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
@ -8689,6 +8750,13 @@ saxes@^6.0.0:
dependencies:
xmlchars "^2.2.0"
scheduler@^0.23.2:
version "0.23.2"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.23.2.tgz#414ba64a3b282892e944cf2108ecc078d115cdc3"
integrity sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==
dependencies:
loose-envify "^1.1.0"
schema-utils@^2.6.5:
version "2.7.1"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"