Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
test: add fail test for issue #10
Browse files Browse the repository at this point in the history
  • Loading branch information
tuananh committed Jun 13, 2020
1 parent 774ee11 commit a9b75a5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ const parse = require('.')
const SaxParser = require('..')

describe('stream test', () => {
// ref: see https://github.com/tuananh/sax-parser/issues/10
test.skip('should be able to parse incomplete stanza in each chunk but complete XML overall', async () => {
expect(() => {
const parser = new SaxParser()
const s = new Readable()

s._read = () => {}

s.push('<foo')
s.push('>world')
s.push('></foo')
s.push('>')
s.push(null)

s.pipe(parser)
}).not.toThrow()
})

test('stream test: 1 root node with 10_000 children elements', async () => {
const expected = [['startElement', 'hello', {}]]
const NUM_CHILDREN = 10_000
Expand All @@ -27,7 +45,7 @@ describe('stream test', () => {
expect(await fn()).toEqual(expected)
})

test('stream test: number of `startElement` and `endElement` ev called should be correct', async () => {
test('number of `startElement` and `endElement` ev called should be correct', async () => {
const parser = new SaxParser()
const s = new Readable()
const COUNT = 1_000_000
Expand Down

0 comments on commit a9b75a5

Please sign in to comment.