const chai = require('chai')
const expect = chai.expect
const { parseOpfMetadataXML } = require('../../../../server/utils/parsers/parseOpfMetadata')
describe('parseOpfMetadata - test series', async () => {
it('test one serie', async() => {
const opf = `
`
const parsedOpf = await parseOpfMetadataXML(opf)
expect(parsedOpf.series).to.deep.equal([{"name": "Serie","sequence": "1"}])
})
it('test more then 1 serie - in correct order', async() => {
const opf = `
`
const parsedOpf = await parseOpfMetadataXML(opf)
expect(parsedOpf.series).to.deep.equal([
{"name": "Serie 1","sequence": "1"},
{"name": "Serie 2","sequence": "2"},
{"name": "Serie 3","sequence": "3"},
])
})
it('test messed order of series content and index', async() => {
const opf = `
`
const parsedOpf = await parseOpfMetadataXML(opf)
expect(parsedOpf.series).to.deep.equal([
{"name": "Serie 1","sequence": "1"},
{"name": "Serie 3","sequence": null},
])
})
it('test different values of series content and index', async() => {
const opf = `
`
const parsedOpf = await parseOpfMetadataXML(opf)
// console.log(JSON.stringify(parsedOpf, null, 4))
expect(parsedOpf.series).to.deep.equal([
{"name": "Serie 1", "sequence": null},
{"name": "Serie 2", "sequence": "abc"},
{"name": "Serie 3", "sequence": null},
])
})
})