mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-11-28 11:22:43 +01:00
Keep iTunes author credentials attached to the name
This commit is contained in:
1 parent
ce41ce489c
commit
087099faa3
2 files changed
+103
-5
No files matched your search
@@ -0,0 +1,53 @@
|
||||
const iTunes = require('../../../server/providers/iTunes')
|
||||
const { expect } = require('chai')
|
||||
|
||||
describe('iTunes', () => {
|
||||
let itunes
|
||||
|
||||
beforeEach(() => {
|
||||
itunes = new iTunes()
|
||||
})
|
||||
|
||||
describe('cleanAudiobook', () => {
|
||||
function authorFrom(artistName) {
|
||||
return itunes.cleanAudiobook({ artistName }).author
|
||||
}
|
||||
|
||||
it('should return an empty string if artistName is missing', () => {
|
||||
expect(authorFrom()).to.equal('')
|
||||
expect(authorFrom('')).to.equal('')
|
||||
})
|
||||
|
||||
it('should keep a single author without commas', () => {
|
||||
expect(authorFrom('Joy Fielding')).to.equal('Joy Fielding')
|
||||
})
|
||||
|
||||
it('should strip commas from a single author with a credential', () => {
|
||||
expect(authorFrom('Rick Hanson, PhD')).to.equal('Rick Hanson PhD')
|
||||
})
|
||||
|
||||
it('should split two authors joined by an ampersand', () => {
|
||||
expect(authorFrom('Name1 & Name2')).to.equal('Name1, Name2')
|
||||
})
|
||||
|
||||
it('should split three authors using commas and an ampersand', () => {
|
||||
expect(authorFrom('Keltie Knight, Becca Tobin & Jac Vanek')).to.equal('Keltie Knight, Becca Tobin, Jac Vanek')
|
||||
})
|
||||
|
||||
it('should glue a one-word credential onto the previous author before the ampersand', () => {
|
||||
expect(authorFrom('Rick Hanson, PhD & Jane Doe')).to.equal('Rick Hanson PhD, Jane Doe')
|
||||
})
|
||||
|
||||
it('should glue several one-word credentials in a row', () => {
|
||||
expect(authorFrom('Rick Hanson, PhD, MD & Jane Doe')).to.equal('Rick Hanson PhD MD, Jane Doe')
|
||||
})
|
||||
|
||||
it('should strip commas from the last author', () => {
|
||||
expect(authorFrom('Rick Hanson & Jane Doe, PhD')).to.equal('Rick Hanson, Jane Doe PhD')
|
||||
})
|
||||
|
||||
it('should glue credentials before the ampersand and strip commas from the last author', () => {
|
||||
expect(authorFrom('Rick Hanson, PhD & Jane Doe, PhD')).to.equal('Rick Hanson PhD, Jane Doe PhD')
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user