Skip to content

Commit

Permalink
Add import test to callback API
Browse files Browse the repository at this point in the history
  • Loading branch information
oozcitak committed Jul 29, 2021
1 parent 797c3db commit 667fa2d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/callback/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ describe('basic callback API tests', () => {
$$.expectCBResult(xmlStream, `<root><?target value?></root>`, done)
})

test('import', (done) => {
const frag1 = $$.fragment().ele("node1")
const frag2 = $$.fragment().ele("node2")

const xmlStream = $$.createCB()

xmlStream.ele("root")
.import(frag1)
.import(frag2)
.end()

$$.expectCBResult(xmlStream, `<root><node1/><node2/></root>`, done)
})

test('nodes at root level', (done) => {
const xmlStream = $$.createCB({ prettyPrint: true })

Expand Down Expand Up @@ -164,4 +178,16 @@ describe('basic callback API tests', () => {
'</root>', done)
})

test('empty ele should throw', (done) => {
const xmlStream = $$.createCB()

$$.expectCBError(xmlStream, () => xmlStream.ele(undefined as any), done)
})

test('empty import should throw', (done) => {
const xmlStream = $$.createCB()

$$.expectCBError(xmlStream, () => xmlStream.import(undefined as any), done)
})

})

0 comments on commit 667fa2d

Please sign in to comment.