Test utils.formatXml().
This commit is contained in:
parent
8f1a31ad13
commit
f572cb5f3e
@ -6,12 +6,13 @@ import expect from 'must'
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
ensureArray,
|
ensureArray,
|
||||||
extractProperty
|
extractProperty,
|
||||||
|
formatXml
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
describe('ensureArray', function () {
|
describe('ensureArray()', function () {
|
||||||
it('wrap the value in an array', function () {
|
it('wrap the value in an array', function () {
|
||||||
const value = 'foo'
|
const value = 'foo'
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ describe('ensureArray', function () {
|
|||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
describe('extractProperty', function () {
|
describe('extractProperty()', function () {
|
||||||
it('returns the value of the property', function () {
|
it('returns the value of the property', function () {
|
||||||
const value = {}
|
const value = {}
|
||||||
const obj = { prop: value }
|
const obj = { prop: value }
|
||||||
@ -47,3 +48,21 @@ describe('extractProperty', function () {
|
|||||||
expect(obj).to.not.have.property('prop')
|
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>`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user