mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-13 06:51:29 +00:00
update
This commit is contained in:
parent
58776ca983
commit
b5e620b981
5 changed files with 419 additions and 0 deletions
|
|
@ -212,4 +212,61 @@ describe('OpenAI', () => {
|
|||
expect(result[1].reason).to.contain('omitted this media file')
|
||||
})
|
||||
})
|
||||
|
||||
describe('validateDuplicateBooksPayload', () => {
|
||||
it('normalizes valid duplicate-book groups', () => {
|
||||
const result = openAI.validateDuplicateBooksPayload(
|
||||
{
|
||||
groups: [
|
||||
{
|
||||
keepId: 'a',
|
||||
duplicateIds: ['b', 'c'],
|
||||
reason: 'same book'
|
||||
}
|
||||
]
|
||||
},
|
||||
[{ id: 'a' }, { id: 'b' }, { id: 'c' }]
|
||||
)
|
||||
|
||||
expect(result).to.deep.equal([
|
||||
{
|
||||
keepId: 'a',
|
||||
duplicateIds: ['b', 'c'],
|
||||
reason: 'same book'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('ignores invalid and overlapping duplicate-book groups', () => {
|
||||
const result = openAI.validateDuplicateBooksPayload(
|
||||
{
|
||||
groups: [
|
||||
{
|
||||
keepId: 'a',
|
||||
duplicateIds: ['b', 'missing', 'a'],
|
||||
reason: 'primary match'
|
||||
},
|
||||
{
|
||||
keepId: 'b',
|
||||
duplicateIds: ['c'],
|
||||
reason: 'should be skipped because b was consumed'
|
||||
},
|
||||
{
|
||||
keepId: 'z',
|
||||
duplicateIds: ['c']
|
||||
}
|
||||
]
|
||||
},
|
||||
[{ id: 'a' }, { id: 'b' }, { id: 'c' }]
|
||||
)
|
||||
|
||||
expect(result).to.deep.equal([
|
||||
{
|
||||
keepId: 'a',
|
||||
duplicateIds: ['b'],
|
||||
reason: 'primary match'
|
||||
}
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue