mirror of
https://github.com/badges/shields.git
synced 2026-11-21 16:06:35 +03:00
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
import { test, given } from 'sazerac'
|
|
import { XmlElement } from './xml.js'
|
|
|
|
function testRender(params) {
|
|
return new XmlElement(params).render()
|
|
}
|
|
|
|
describe('XmlElement class', function () {
|
|
test(testRender, () => {
|
|
given({ name: 'tag' }).expect('<tag/>')
|
|
|
|
given({ name: 'tag', content: ['text'] }).expect('<tag>text</tag>')
|
|
|
|
given({
|
|
name: 'tag',
|
|
content: ['not xml>>>', 'text', new XmlElement({ name: 'xml' })],
|
|
}).expect('<tag>not xml>>> text <xml/></tag>')
|
|
|
|
given({
|
|
name: 'nested1',
|
|
content: [
|
|
new XmlElement({
|
|
name: 'nested2',
|
|
content: [new XmlElement({ name: 'nested3' })],
|
|
}),
|
|
],
|
|
}).expect('<nested1><nested2><nested3/></nested2></nested1>')
|
|
|
|
given({
|
|
name: 'tag',
|
|
attrs: {
|
|
int: 47,
|
|
text: 'text',
|
|
escape: '<escape me>',
|
|
},
|
|
}).expect('<tag int="47" text="text" escape="<escape me>"/>')
|
|
|
|
given({
|
|
name: 'tag',
|
|
content: ['text'],
|
|
attrs: {
|
|
int: 47,
|
|
text: 'text',
|
|
escape: '<escape me>',
|
|
},
|
|
}).expect('<tag int="47" text="text" escape="<escape me>">text</tag>')
|
|
})
|
|
})
|