typescriptify and cleanup
This commit is contained in:
30
test/cdata_and_comments.spec.ts
Normal file
30
test/cdata_and_comments.spec.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import fs from "fs";
|
||||
import "mocha";
|
||||
import should from "should";
|
||||
import stream from "stream";
|
||||
import zlib from "zlib";
|
||||
|
||||
import { XmlParser } from "../src/parser";
|
||||
describe("CData and comments in xml", () => {
|
||||
it("should properly parse a simple file.", (done) => {
|
||||
const xmlStream = fs.createReadStream("./test/TestFiles/CData-comments.xml");
|
||||
const parser = new XmlParser({ resourcePath: "/items/item" });
|
||||
|
||||
let dataEventCount = 0;
|
||||
|
||||
parser.on("data", (data) => {
|
||||
dataEventCount++;
|
||||
});
|
||||
|
||||
parser.on("error", (err) => {
|
||||
done(err);
|
||||
});
|
||||
|
||||
parser.on("end", () => {
|
||||
// console.log('dataEventCount=', dataEventCount)
|
||||
should(dataEventCount).equal(296);
|
||||
done();
|
||||
});
|
||||
xmlStream.pipe(parser);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user