const chai = require('chai') const expect = chai.expect const { parseOpfMetadataXML } = require('../../../../server/utils/parsers/parseOpfMetadata') describe('parseOpfMetadata - test series', async () => { it('test one series', async () => { const opf = ` ` const parsedOpf = await parseOpfMetadataXML(opf) expect(parsedOpf.series).to.deep.equal([{ "name": "Serie", "sequence": "1" }]) }) it('test more then 1 series - 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) expect(parsedOpf.series).to.deep.equal([ { "name": "Serie 1", "sequence": null }, { "name": "Serie 2", "sequence": "abc" }, { "name": "Serie 3", "sequence": null }, ]) }) it('test empty series content', async () => { const opf = ` ` const parsedOpf = await parseOpfMetadataXML(opf) expect(parsedOpf.series).to.deep.equal([]) }) it('test series and index using an xml namespace', async () => { const opf = ` ` const parsedOpf = await parseOpfMetadataXML(opf) expect(parsedOpf.series).to.deep.equal([ { "name": "Serie 1", "sequence": null } ]) }) it('test series and series index not directly underneath', async () => { const opf = ` ` const parsedOpf = await parseOpfMetadataXML(opf) expect(parsedOpf.series).to.deep.equal([ { "name": "Serie 1", "sequence": "1" } ]) }) })