mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-25 01:16:40 +02:00
Add test for parseOpfMetadata OPF v3 author
This commit is contained in:
parent
de22177dbf
commit
804dafdfcb
@ -3,8 +3,8 @@ const expect = chai.expect
|
||||
const { parseOpfMetadataXML } = require('../../../../server/utils/parsers/parseOpfMetadata')
|
||||
|
||||
describe('parseOpfMetadata - test series', async () => {
|
||||
it('test one series', async () => {
|
||||
const opf = `
|
||||
it('test one series', async () => {
|
||||
const opf = `
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<package xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" xml:lang="en" version="3.0" unique-identifier="bookid">
|
||||
<metadata>
|
||||
@ -13,12 +13,12 @@ describe('parseOpfMetadata - test series', async () => {
|
||||
</metadata>
|
||||
</package>
|
||||
`
|
||||
const parsedOpf = await parseOpfMetadataXML(opf)
|
||||
expect(parsedOpf.series).to.deep.equal([{ "name": "Serie", "sequence": "1" }])
|
||||
})
|
||||
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 = `
|
||||
it('test more then 1 series - in correct order', async () => {
|
||||
const opf = `
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<package xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" xml:lang="en" version="3.0" unique-identifier="bookid">
|
||||
<metadata>
|
||||
@ -31,16 +31,16 @@ describe('parseOpfMetadata - test series', async () => {
|
||||
</metadata>
|
||||
</package>
|
||||
`
|
||||
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" },
|
||||
])
|
||||
})
|
||||
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 = `
|
||||
it('test messed order of series content and index', async () => {
|
||||
const opf = `
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<package xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" xml:lang="en" version="3.0" unique-identifier="bookid">
|
||||
<metadata>
|
||||
@ -52,15 +52,15 @@ describe('parseOpfMetadata - test series', async () => {
|
||||
</metadata>
|
||||
</package>
|
||||
`
|
||||
const parsedOpf = await parseOpfMetadataXML(opf)
|
||||
expect(parsedOpf.series).to.deep.equal([
|
||||
{ "name": "Serie 1", "sequence": "1" },
|
||||
{ "name": "Serie 3", "sequence": null },
|
||||
])
|
||||
})
|
||||
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 = `
|
||||
it('test different values of series content and index', async () => {
|
||||
const opf = `
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<package xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" xml:lang="en" version="3.0" unique-identifier="bookid">
|
||||
<metadata>
|
||||
@ -73,16 +73,16 @@ describe('parseOpfMetadata - test series', async () => {
|
||||
</metadata>
|
||||
</package>
|
||||
`
|
||||
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 },
|
||||
])
|
||||
})
|
||||
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 = `
|
||||
it('test empty series content', async () => {
|
||||
const opf = `
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<package xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" xml:lang="en" version="3.0" unique-identifier="bookid">
|
||||
<metadata>
|
||||
@ -91,12 +91,12 @@ describe('parseOpfMetadata - test series', async () => {
|
||||
</metadata>
|
||||
</package>
|
||||
`
|
||||
const parsedOpf = await parseOpfMetadataXML(opf)
|
||||
expect(parsedOpf.series).to.deep.equal([])
|
||||
})
|
||||
const parsedOpf = await parseOpfMetadataXML(opf)
|
||||
expect(parsedOpf.series).to.deep.equal([])
|
||||
})
|
||||
|
||||
it('test series and index using an xml namespace', async () => {
|
||||
const opf = `
|
||||
it('test series and index using an xml namespace', async () => {
|
||||
const opf = `
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<ns0:package xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" xml:lang="en" version="3.0" unique-identifier="bookid">
|
||||
<ns0:metadata>
|
||||
@ -105,14 +105,12 @@ describe('parseOpfMetadata - test series', async () => {
|
||||
</ns0:metadata>
|
||||
</ns0:package>
|
||||
`
|
||||
const parsedOpf = await parseOpfMetadataXML(opf)
|
||||
expect(parsedOpf.series).to.deep.equal([
|
||||
{ "name": "Serie 1", "sequence": null }
|
||||
])
|
||||
})
|
||||
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 = `
|
||||
it('test series and series index not directly underneath', async () => {
|
||||
const opf = `
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<package xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" xml:lang="en" version="3.0" unique-identifier="bookid">
|
||||
<metadata>
|
||||
@ -122,9 +120,21 @@ describe('parseOpfMetadata - test series', async () => {
|
||||
</metadata>
|
||||
</package>
|
||||
`
|
||||
const parsedOpf = await parseOpfMetadataXML(opf)
|
||||
expect(parsedOpf.series).to.deep.equal([
|
||||
{ "name": "Serie 1", "sequence": "1" }
|
||||
])
|
||||
})
|
||||
const parsedOpf = await parseOpfMetadataXML(opf)
|
||||
expect(parsedOpf.series).to.deep.equal([{ name: 'Serie 1', sequence: '1' }])
|
||||
})
|
||||
|
||||
it('test author is parsed from refines meta', async () => {
|
||||
const opf = `
|
||||
<package version="3.0" unique-identifier="uuid_id" prefix="rendition: http://www.idpf.org/vocab/rendition/#" xmlns="http://www.idpf.org/2007/opf">
|
||||
<metadata>
|
||||
<dc:creator id="create1">Nevil Shute</dc:creator>
|
||||
<meta refines="#create1" property="role" scheme="marc:relators">aut</meta>
|
||||
<meta refines="#create1" property="file-as">Shute, Nevil</meta>
|
||||
</metadata>
|
||||
</package>
|
||||
`
|
||||
const parsedOpf = await parseOpfMetadataXML(opf)
|
||||
expect(parsedOpf.authors).to.deep.equal(['Nevil Shute'])
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user