19 lines
826 B
TypeScript
19 lines
826 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { xmlElementStartLines } from '../../server/gpo/xml-source-lines';
|
|
|
|
describe('XML source-line provenance', () => {
|
|
it('tracks mixed line endings while ignoring commented-out items', () => {
|
|
const text = '<Root>\r\n<Item/>\n<!--\r<Item/>\n-->\r<Item/>\n</Root>';
|
|
expect(xmlElementStartLines(text, /<Item(?=[\s/>])/g)).toEqual([2, 6]);
|
|
});
|
|
|
|
it('scans the maximum supported Preference item count without prefix copies', () => {
|
|
const count = 20_000;
|
|
const text = `<Root>\n${Array.from({ length: count }, (_, index) => `<Item id="${index}"/>`).join('\n')}\n</Root>`;
|
|
const lines = xmlElementStartLines(text, /<Item(?=[\s/>])/g);
|
|
expect(lines).toHaveLength(count);
|
|
expect(lines[0]).toBe(2);
|
|
expect(lines.at(-1)).toBe(count + 1);
|
|
});
|
|
});
|