| 5 | describe('Saxy XML Parser', () => { |
| 6 | // Helper function to process XML and get events |
| 7 | const processXML = ( |
| 8 | xml: string, |
| 9 | schema?: Record<string, string[]>, |
| 10 | shouldParseEntities = true, |
| 11 | ) => { |
| 12 | const events: Array<{ type: string; data: any }> = [] |
| 13 | const parser = new Saxy(schema, shouldParseEntities) |
| 14 | |
| 15 | parser.on('text', (data) => events.push({ type: 'text', data })) |
| 16 | parser.on('tagopen', (data) => events.push({ type: 'tagopen', data })) |
| 17 | parser.on('tagclose', (data) => events.push({ type: 'tagclose', data })) |
| 18 | |
| 19 | parser.write(xml) |
| 20 | parser.end() |
| 21 | |
| 22 | return events |
| 23 | } |
| 24 | |
| 25 | describe('Schema Validation with Text Conversion', () => { |
| 26 | it('should convert invalid top-level tags to text nodes', () => { |