@@ -6,6 +6,7 @@ import { XmlAttribute } from './model/xmlAttribute';
66import { XmlElement } from './model/xmlElement' ;
77import { XmlParser } from './xmlParser' ;
88import { XmlDocument } from './model/xmlDocument' ;
9+ import { XmlCData } from './model/xmlCData' ;
910
1011describe ( 'XmlParser' , ( ) => {
1112 describe ( 'parse' , ( ) => {
@@ -28,8 +29,9 @@ describe('XmlParser', () => {
2829 const xml = `<?xml version="1.0" encoding="UTF-8"?>
2930<root>
3031 <!-- my comment -->
31- <element attribute="value" />
32- <element attribute='value'></element>
32+ <self-closing attribute="value with double quotes" />
33+ <non-self-closing attribute='value with single quotes'></non-self-closing>
34+ <element-with-cdata><![CDATA[<html>]]></element-with-cdata>
3335</root>` ;
3436 const doc = XmlParser . parse ( xml ) ;
3537 expect ( doc ) . toEqual ( new XmlDocument ( [
@@ -39,9 +41,11 @@ describe('XmlParser', () => {
3941 new XmlText ( '\n ' ) ,
4042 new XmlComment ( ' my comment ' ) ,
4143 new XmlText ( '\n ' ) ,
42- new XmlElement ( 'element ' , [ new XmlAttribute ( 'attribute' , 'value' ) ] , [ ] , ' ' , true ) ,
44+ new XmlElement ( 'self-closing ' , [ new XmlAttribute ( 'attribute' , 'value with double quotes ' ) ] , [ ] , ' ' , true ) ,
4345 new XmlText ( '\n ' ) ,
44- new XmlElement ( 'element' , [ new XmlAttribute ( 'attribute' , 'value' , ' ' , '' , '' , "'" ) ] , [ ] , '' , false ) ,
46+ new XmlElement ( 'non-self-closing' , [ new XmlAttribute ( 'attribute' , 'value with single quotes' , ' ' , '' , '' , "'" ) ] , [ ] , '' , false ) ,
47+ new XmlText ( '\n ' ) ,
48+ new XmlElement ( 'element-with-cdata' , [ ] , [ new XmlCData ( '<html>' ) ] ) ,
4549 new XmlText ( '\n' )
4650 ] )
4751 ] ) ) ;
0 commit comments