Files
formipay/node_modules/comment-parser/tests/unit/util.spec.ts
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

131 lines
2.7 KiB
TypeScript

import {
hasCR,
isSpace,
seedTokens,
seedBlock,
splitLines,
splitSpace,
seedSpec,
} from '../../src/util.js';
test.each([
['beginning', '\r to end', false],
['middle', 'has \r in middle', false],
['ending', 'only at end \r', true],
['none', 'no carriage returns', false],
])('carriage returns - %s', (name, source, boolResult) => {
expect(hasCR(source)).toEqual(boolResult);
});
test.each([
['win', 'a\r\nb\r\nc', ['a\r', 'b\r', 'c']],
['unix', 'a\nb\nc', ['a', 'b', 'c']],
['mixed', 'a\nb\r\nc', ['a', 'b\r', 'c']],
['none', 'abc', ['abc']],
])('spliLines - %s', (name, source, parsed) =>
expect(splitLines(source)).toEqual(parsed)
);
test.each([
['pre', ' abc', [' ', 'abc']],
['pre', 'abc ', ['', 'abc ']],
['pre+post', ' abc ', [' ', 'abc ']],
['none', 'abc', ['', 'abc']],
])('spliSpace - %s', (name, source, parsed) =>
expect(splitSpace(source)).toEqual(parsed)
);
test.each([
['space', ' ', true],
['spaces', ' ', true],
['tab', '\t', true],
['tabs', '\t\t', true],
['line end', '\n', true],
['line ends', '\n\n', true],
['line return', '\r', true],
['line returns', '\r\r', true],
['mixed space', '\n\r\t', true],
['mixed', '\naba', false],
['alpahnumeric', '1abcd34', false],
['symbols', '*', false],
['empty', '', false],
])('isSpace - %s', (name, source, result) =>
expect(isSpace(source)).toBe(result)
);
test('seedTokens defaults', () => {
expect(seedTokens()).toEqual({
start: '',
delimiter: '',
postDelimiter: '',
tag: '',
postTag: '',
name: '',
postName: '',
type: '',
postType: '',
description: '',
end: '',
lineEnd: '',
});
});
test('seedTokens overrides', () => {
expect(seedTokens({ description: 'abc' })).toEqual({
start: '',
delimiter: '',
postDelimiter: '',
tag: '',
postTag: '',
name: '',
postName: '',
type: '',
postType: '',
description: 'abc',
end: '',
lineEnd: '',
});
});
test('seedBlock defaults', () => {
expect(seedBlock()).toEqual({
description: '',
tags: [],
source: [],
problems: [],
});
});
test('seedBlock overrides', () => {
expect(seedBlock({ description: 'abc' })).toEqual({
description: 'abc',
tags: [],
source: [],
problems: [],
});
});
test('seedSpec defaults', () => {
expect(seedSpec()).toEqual({
tag: '',
name: '',
type: '',
optional: false,
description: '',
problems: [],
source: [],
});
});
test('seedSpec overrides', () => {
expect(seedSpec({ description: 'abc' })).toEqual({
tag: '',
name: '',
type: '',
optional: false,
description: 'abc',
problems: [],
source: [],
});
});