Test utils.formatXml().

This commit is contained in:
Julien Fontanet 2015-06-11 17:25:58 +02:00
parent 8f1a31ad13
commit f572cb5f3e

View File

@ -6,12 +6,13 @@ import expect from 'must'
import {
ensureArray,
extractProperty
extractProperty,
formatXml
} from './utils'
// ===================================================================
describe('ensureArray', function () {
describe('ensureArray()', function () {
it('wrap the value in an array', function () {
const value = 'foo'
@ -31,7 +32,7 @@ describe('ensureArray', function () {
// -------------------------------------------------------------------
describe('extractProperty', function () {
describe('extractProperty()', function () {
it('returns the value of the property', function () {
const value = {}
const obj = { prop: value }
@ -47,3 +48,21 @@ describe('extractProperty', function () {
expect(obj).to.not.have.property('prop')
})
})
// -------------------------------------------------------------------
describe('formatXml()', function () {
it('formats a JS object to an XML string', function () {
expect(formatXml({
foo: {
bar: [
{$: {baz: 'plop'}},
{$: {baz: 'plip'}}
]
}
})).to.equal(`<foo>
<bar baz="plop"/>
<bar baz="plip"/>
</foo>`)
})
})