1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 | const parse = require('./lib/parse')
|
6 | const { test } = require('tap')
|
7 |
|
8 | test('whitespace', (t) => {
|
9 | const xml = 'wtf'
|
10 |
|
11 | const wanted = [
|
12 | ['error', new Error('undefined:1:1: text data outside of root node.')],
|
13 | ['error', new Error('undefined:1:3: document must contain a root element.')],
|
14 | ['finish'],
|
15 | ['end']
|
16 | ]
|
17 |
|
18 | parse({ t: t, xml: xml, wanted: wanted, size: Infinity }, (er) => {
|
19 | t.ok(!er)
|
20 | t.end()
|
21 | })
|
22 | })
|
23 |
|
24 | test('gibberish', (t) => {
|
25 | const xml = '<wtf>'
|
26 |
|
27 | const wanted = [
|
28 | ['error', new Error('undefined:1:5: unclosed tag: wtf')],
|
29 | ['finish'],
|
30 | ['end']
|
31 | ]
|
32 |
|
33 | parse({ t: t, xml: xml, wanted: wanted, size: Infinity }, (er) => {
|
34 | t.ok(!er)
|
35 | t.end()
|
36 | })
|
37 | })
|