@@ -15,16 +15,16 @@ describe('Node-Libxml', function () {
1515 libxml . freeDtds ( ) ;
1616 } ) ;
1717 // Wellformed & valid
18- // it('Should return wellformed & valid on a wellformed & valid xml', function () {
19- // let libxml = new Libxml();
20- // let testDefaultWf = libxml.loadXml('test/data/test-default.xml');
21- // libxml.loadDtds(['test/dtd/mydoctype.dtd']);
22- // let testDefaultV = libxml.validateAgainstDtds();
23- // expect(testDefaultWf).to.be.true;
24- // expect(testDefaultV).to.be.a('string');
25- // libxml.freeXml();
26- // libxml.freeDtds();
27- // });
18+ it ( 'Should return wellformed & valid on a wellformed & valid xml' , function ( ) {
19+ let libxml = new Libxml ( ) ;
20+ let testDefaultWf = libxml . loadXml ( 'test/data/test-default.xml' ) ;
21+ libxml . loadDtds ( [ 'test/dtd/mydoctype.dtd' ] ) ;
22+ let testDefaultV = libxml . validateAgainstDtds ( ) ;
23+ expect ( testDefaultWf ) . to . be . true ;
24+ expect ( testDefaultV ) . to . be . a ( 'string' ) ;
25+ libxml . freeXml ( ) ;
26+ libxml . freeDtds ( ) ;
27+ } ) ;
2828 // // it('Should return wellformed & valid on a wellformed & valid xml From String', function () {
2929 // // let libxml = new Libxml();
3030 // // let testDefaultStr = fs.readFileSync('test/data/test-default.xml','utf8');
@@ -59,42 +59,42 @@ describe('Node-Libxml', function () {
5959 expect ( libxml ) . not . have . property ( "wellFormedErrors" ) ;
6060 libxml . freeXml ( ) ;
6161 } ) ;
62- // // Wellformed & invalid
63- // it('Should return wellformed & invalid on a wellformed BUT invalid xml', function () {
64- // let libxml = new Libxml();
65- // let testInvalidWf = libxml.loadXml('test/data/test-not-valid-dtd.xml');
66- // libxml.loadDtds(['test/dtd/mydoctype.dtd']);
67- // let testInvalid = libxml.validateAgainstDtds(3);
68- // expect(testInvalidWf).to.be.true;
69- // expect(testInvalid).to.be.false;
70- // expect(libxml).to.have.property('validationDtdErrors');
71- // expect(libxml.validationDtdErrors).to.be.an('object');
72- // expect(libxml.validationDtdErrors['test/dtd/mydoctype.dtd'].length).to.be.equal(3);
73- // libxml.freeDtds();
74- // libxml.freeXml();
75- // });
76- // it('Should return wellformed & invalid on a wellformed BUT invalid xml FROM STRING XML', function () {
77- // let libxml = new Libxml();
78- // let testInvalidWfStr = fs.readFileSync('test/data/test-not-valid-dtd.xml');
79- // let testInvalidWf = libxml.loadXmlFromString(testInvalidWfStr);
80- // libxml.loadDtds(['test/dtd/mydoctype.dtd']);
81- // let testInvalid = libxml.validateAgainstDtds(3);
82- // expect(testInvalidWf).to.be.true;
83- // expect(testInvalid).to.be.false;
84- // expect(libxml).to.have.property('validationDtdErrors');
85- // expect(libxml.validationDtdErrors).to.be.an('object');
86- // expect(libxml.validationDtdErrors['test/dtd/mydoctype.dtd'].length).to.be.equal(3);
87- // libxml.freeDtds();
88- // libxml.freeXml();
89- // });
62+ // Wellformed & invalid
63+ it ( 'Should return wellformed & invalid on a wellformed BUT invalid xml' , function ( ) {
64+ let libxml = new Libxml ( ) ;
65+ let testInvalidWf = libxml . loadXml ( 'test/data/test-not-valid-dtd.xml' ) ;
66+ libxml . loadDtds ( [ 'test/dtd/mydoctype.dtd' ] ) ;
67+ let testInvalid = libxml . validateAgainstDtds ( 3 ) ;
68+ expect ( testInvalidWf ) . to . be . true ;
69+ expect ( testInvalid ) . to . be . false ;
70+ expect ( libxml ) . to . have . property ( 'validationDtdErrors' ) ;
71+ expect ( libxml . validationDtdErrors ) . to . be . an ( 'object' ) ;
72+ expect ( libxml . validationDtdErrors [ 'test/dtd/mydoctype.dtd' ] . length ) . to . be . equal ( 3 ) ;
73+ libxml . freeDtds ( ) ;
74+ libxml . freeXml ( ) ;
75+ } ) ;
76+ it ( 'Should return wellformed & invalid on a wellformed BUT invalid xml FROM STRING XML' , function ( ) {
77+ let libxml = new Libxml ( ) ;
78+ let testInvalidWfStr = fs . readFileSync ( 'test/data/test-not-valid-dtd.xml' , 'utf8 ') ;
79+ let testInvalidWf = libxml . loadXmlFromString ( testInvalidWfStr ) ;
80+ libxml . loadDtds ( [ 'test/dtd/mydoctype.dtd' ] ) ;
81+ let testInvalid = libxml . validateAgainstDtds ( 3 ) ;
82+ expect ( testInvalidWf ) . to . be . true ;
83+ expect ( testInvalid ) . to . be . false ;
84+ expect ( libxml ) . to . have . property ( 'validationDtdErrors' ) ;
85+ expect ( libxml . validationDtdErrors ) . to . be . an ( 'object' ) ;
86+ expect ( libxml . validationDtdErrors [ 'test/dtd/mydoctype.dtd' ] . length ) . to . be . equal ( 3 ) ;
87+ libxml . freeDtds ( ) ;
88+ libxml . freeXml ( ) ;
89+ } ) ;
9090 // not wellformed
9191 it ( 'Should return Not Wellformed & invalid on a not wellformed xml' , function ( ) {
9292 let libxml = new Libxml ( ) ;
9393 let wellformed = libxml . loadXml ( 'test/data/test-not-wellformed.xml' ) ;
94- // libxml.loadDtds(['test/dtd/mydoctype.dtd']);
95- // let wellformedV = libxml.validateAgainstDtds();
94+ libxml . loadDtds ( [ 'test/dtd/mydoctype.dtd' ] ) ;
95+ let wellformedV = libxml . validateAgainstDtds ( ) ;
9696 expect ( wellformed ) . to . be . false ;
97- // expect(wellformedV).to.be.false;
97+ expect ( wellformedV ) . to . be . false ;
9898 expect ( libxml ) . to . have . property ( 'wellformedErrors' ) ;
9999 expect ( libxml . wellformedErrors ) . to . be . an ( 'array' ) ;
100100 libxml . freeXml ( ) ;
@@ -142,62 +142,62 @@ describe('Node-Libxml', function () {
142142 // libxml.freeXml();
143143 // });
144144 // // // ABOVE IS ALL THE SAME WITH MEMORY MANUAL MANADGEMENT
145- // it('should free XML memory & infos when asked in manual mod On not wellformed xml', function () {
146- // let libxml = new Libxml(true);
147- // let wellformed = libxml.loadXml('test/data/test-not-wellformed.xml');
148- // expect(wellformed).to.be.false;
149- // expect(libxml).to.have.property('wellformedErrors');
150- // expect(libxml.wellformedErrors).to.be.an('array');
151- // expect(libxml.wellformedErrors.length).to.be.at.least(1);
152- // libxml.freeXml();
153- // expect(libxml).not.to.have.property('wellformedErrors');
154- // });
155- // it('should not crash when freeUp memory xml multiple time!', function () {
156- // let libxml = new Libxml(true);
157- // let wellFormed = libxml.loadXml('test/data/test-default.xml');
158- // expect(wellFormed).to.be.true;
159- // expect(libxml).not.to.have.property('wellformedErrors');
160- // libxml.freeXml();
161- // libxml.freeXml();
162- // libxml.freeXml();
163- // expect(libxml).not.to.have.property('wellformedErrors');
164- // });
165- // it('Should return intended values after multiple CLEAN!', function () {
166- // let libxml = new Libxml();
167- // let wellformed = libxml.loadXml('test/data/test-not-valid-dtd.xml');
168- // libxml.loadDtds(['test/dtd/mydoctype.dtd']);
169- // let wellformedV = libxml.validateAgainstDtds();
170- // expect(wellformed).to.be.true;
171- // expect(wellformedV).to.be.false;
172- // expect(libxml).to.not.have.property('wellformedErrors');
173- // libxml.freeXml();
174- // libxml.freeDtds();
175- // libxml.freeDtds();
176- // wellformed = libxml.loadXml('test/data/test-default.xml');
177- // libxml.loadDtds(['test/dtd/mydoctype.dtd', 'test/dtd/myBADdoctype.dtd']);
178- // wellformedV = libxml.validateAgainstDtds();
179- // expect(wellformed).to.be.true;
180- // expect(wellformedV).to.be.a('string');
181- // expect(wellformedV).to.be.equal('test/dtd/mydoctype.dtd');
182- // expect(libxml).to.not.have.property('wellformedErrors');
183- // });
184- // it('should not crash when loads multiple dtd it two times ', function () {
185- // let libxml = new Libxml();
186- // let wellformed = libxml.loadXml('test/data/test-not-valid-dtd.xml');
187- // libxml.loadDtds(['test/dtd/mydoctype.dtd', 'test/dtd/myBADdoctype.dtd']);
188- // libxml.loadDtds(['test/dtd/mydoctype2.dtd', 'test/dtd/myBADdoctype2.dtd']);
189- // let wellformedV = libxml.validateAgainstDtds();
190- // expect(wellformed).to.be.true;
191- // expect(wellformedV).to.be.false;
192- // expect(libxml).to.not.have.property('wellformedErrors');
193- // expect(libxml).to.have.property('validationDtdErrors');
194- // expect(libxml.validationDtdErrors).to.have.property('test/dtd/mydoctype.dtd');
195- // expect(libxml.validationDtdErrors).to.have.property('test/dtd/mydoctype2 .dtd');
196- // expect(libxml.validationDtdErrors).to.have.property('test/dtd/mydoctype2.dtd');
197- // expect(libxml.validationDtdErrors).to.have.property('test/dtd/myBADdoctype2.dtd');
198- // libxml.freeXml();
199- // libxml.freeDtds();
200- // });
145+ it ( 'should free XML memory & infos when asked in manual mod On not wellformed xml' , function ( ) {
146+ let libxml = new Libxml ( true ) ;
147+ let wellformed = libxml . loadXml ( 'test/data/test-not-wellformed.xml' ) ;
148+ expect ( wellformed ) . to . be . false ;
149+ expect ( libxml ) . to . have . property ( 'wellformedErrors' ) ;
150+ expect ( libxml . wellformedErrors ) . to . be . an ( 'array' ) ;
151+ expect ( libxml . wellformedErrors . length ) . to . be . at . least ( 1 ) ;
152+ libxml . freeXml ( ) ;
153+ expect ( libxml ) . not . to . have . property ( 'wellformedErrors' ) ;
154+ } ) ;
155+ it ( 'should not crash when freeUp memory xml multiple time!' , function ( ) {
156+ let libxml = new Libxml ( true ) ;
157+ let wellFormed = libxml . loadXml ( 'test/data/test-default.xml' ) ;
158+ expect ( wellFormed ) . to . be . true ;
159+ expect ( libxml ) . not . to . have . property ( 'wellformedErrors' ) ;
160+ libxml . freeXml ( ) ;
161+ libxml . freeXml ( ) ;
162+ libxml . freeXml ( ) ;
163+ expect ( libxml ) . not . to . have . property ( 'wellformedErrors' ) ;
164+ } ) ;
165+ it ( 'Should return intended values after multiple CLEAN!' , function ( ) {
166+ let libxml = new Libxml ( ) ;
167+ let wellformed = libxml . loadXml ( 'test/data/test-not-valid-dtd.xml' ) ;
168+ libxml . loadDtds ( [ 'test/dtd/mydoctype.dtd' ] ) ;
169+ let wellformedV = libxml . validateAgainstDtds ( ) ;
170+ expect ( wellformed ) . to . be . true ;
171+ expect ( wellformedV ) . to . be . false ;
172+ expect ( libxml ) . to . not . have . property ( 'wellformedErrors' ) ;
173+ libxml . freeXml ( ) ;
174+ libxml . freeDtds ( ) ;
175+ libxml . freeDtds ( ) ;
176+ wellformed = libxml . loadXml ( 'test/data/test-default.xml' ) ;
177+ libxml . loadDtds ( [ 'test/dtd/mydoctype.dtd' , 'test/dtd/myBADdoctype.dtd' ] ) ;
178+ wellformedV = libxml . validateAgainstDtds ( ) ;
179+ expect ( wellformed ) . to . be . true ;
180+ expect ( wellformedV ) . to . be . a ( 'string' ) ;
181+ expect ( wellformedV ) . to . be . equal ( 'test/dtd/mydoctype.dtd' ) ;
182+ expect ( libxml ) . to . not . have . property ( 'wellformedErrors' ) ;
183+ } ) ;
184+ it ( 'should not crash when loads multiple dtd in two rounds ' , function ( ) {
185+ let libxml = new Libxml ( ) ;
186+ let wellformed = libxml . loadXml ( 'test/data/test-not-valid-dtd.xml' ) ;
187+ libxml . loadDtds ( [ 'test/dtd/mydoctype.dtd' , 'test/dtd/myBADdoctype.dtd' ] ) ;
188+ libxml . loadDtds ( [ 'test/dtd/mydoctype2.dtd' , 'test/dtd/myBADdoctype2.dtd' ] ) ;
189+ let wellformedV = libxml . validateAgainstDtds ( ) ;
190+ expect ( wellformed ) . to . be . true ;
191+ expect ( wellformedV ) . to . be . false ;
192+ expect ( libxml ) . to . not . have . property ( 'wellformedErrors' ) ;
193+ expect ( libxml ) . to . have . property ( 'validationDtdErrors' ) ;
194+ expect ( libxml . validationDtdErrors ) . to . have . property ( 'test/dtd/mydoctype.dtd' ) ;
195+ expect ( libxml . validationDtdErrors ) . to . have . property ( 'test/dtd/myBADdoctype .dtd' ) ;
196+ expect ( libxml . validationDtdErrors ) . to . have . property ( 'test/dtd/mydoctype2.dtd' ) ;
197+ expect ( libxml . validationDtdErrors ) . to . have . property ( 'test/dtd/myBADdoctype2.dtd' ) ;
198+ libxml . freeXml ( ) ;
199+ libxml . freeDtds ( ) ;
200+ } ) ;
201201 // // SCHEMAS
202202 // it('Should return wellformed & valid on a wellformed & valid xml SCHEMA', function () {
203203 // let libxml = new Libxml();
0 commit comments