* Rewrite for-the-badge renderer * Update snapshots * Remove pixel grid alignment in for-the-badge * abstract XML stringification to XmlElement class Co-authored-by: chris48s <chris48s@users.noreply.github.com> Co-authored-by: chris48s <chris.shaw480@gmail.com>
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const { test, given } = require('sazerac')
|
|
const { XmlElement } = require('./xml')
|
|
|
|
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>')
|
|
})
|
|
})
|