Files
formipay/node_modules/@wordpress/jest-console/build/matchers.js
dwindown e8fbfb14c1 fix: prevent asset conflicts between React and Grid.js versions
Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 17:02:14 +07:00

63 lines
2.3 KiB
JavaScript

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _jestMatcherUtils = require("jest-matcher-utils");
var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"));
/**
* External dependencies
*/
/**
* Internal dependencies
*/
const createErrorMessage = spyInfo => {
const {
spy,
pass,
calls,
matcherName,
methodName,
expected
} = spyInfo;
const hint = pass ? `.not${matcherName}` : matcherName;
const message = pass ? `Expected mock function not to be called but it was called with:\n${calls.map(_jestMatcherUtils.printReceived)}` : `Expected mock function to be called${expected ? ` with:\n${(0, _jestMatcherUtils.printExpected)(expected)}\n` : '.'}\nbut it was called with:\n${calls.map(_jestMatcherUtils.printReceived)}`;
return () => `${(0, _jestMatcherUtils.matcherHint)(hint, spy.getMockName())}` + '\n\n' + message + '\n\n' + `console.${methodName}() should not be used unless explicitly expected\n` + 'See https://www.npmjs.com/package/@wordpress/jest-console for details.';
};
const createSpyInfo = (spy, matcherName, methodName, expected) => {
const calls = spy.mock.calls;
const pass = expected ? JSON.stringify(calls).includes(JSON.stringify(expected)) : calls.length > 0;
const message = createErrorMessage({
spy,
pass,
calls,
matcherName,
methodName,
expected
});
return {
pass,
message
};
};
const createToHaveBeenCalledMatcher = (matcherName, methodName) => received => {
const spy = received[methodName];
const spyInfo = createSpyInfo(spy, matcherName, methodName);
spy.assertionsNumber += 1;
return spyInfo;
};
const createToHaveBeenCalledWith = (matcherName, methodName) => function (received, ...expected) {
const spy = received[methodName];
const spyInfo = createSpyInfo(spy, matcherName, methodName, expected);
spy.assertionsNumber += 1;
return spyInfo;
};
expect.extend(Object.entries(_supportedMatchers.default).reduce((result, [methodName, matcherName]) => {
const matcherNameWith = `${matcherName}With`;
return {
...result,
[matcherName]: createToHaveBeenCalledMatcher(`.${matcherName}`, methodName),
[matcherNameWith]: createToHaveBeenCalledWith(`.${matcherNameWith}`, methodName)
};
}, {}));
//# sourceMappingURL=matchers.js.map