mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-13 21:01:39 +00:00
Fix punctuation-insensitive library search
This commit is contained in:
parent
2d0a5462d2
commit
9491db51de
2 changed files with 63 additions and 3 deletions
44
test/server/utils/queries/libraryItemsBookFilters.test.js
Normal file
44
test/server/utils/queries/libraryItemsBookFilters.test.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
const { expect } = require('chai')
|
||||
const { Sequelize } = require('sequelize')
|
||||
|
||||
const Database = require('../../../../server/Database')
|
||||
const libraryItemsBookFilters = require('../../../../server/utils/queries/libraryItemsBookFilters')
|
||||
|
||||
describe('libraryItemsBookFilters.search', () => {
|
||||
beforeEach(async () => {
|
||||
global.ServerSettings = {}
|
||||
Database.sequelize = new Sequelize({ dialect: 'sqlite', storage: ':memory:', logging: false })
|
||||
Database.sequelize.uppercaseFirst = (str) => (str ? `${str[0].toUpperCase()}${str.substr(1)}` : '')
|
||||
Database.supportsUnaccent = false
|
||||
await Database.buildModels()
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await Database.sequelize.close()
|
||||
})
|
||||
|
||||
it('matches titles when the query omits commas', async () => {
|
||||
const library = await Database.libraryModel.create({ name: 'Test Library', mediaType: 'book' })
|
||||
const libraryFolder = await Database.libraryFolderModel.create({ path: '/test', libraryId: library.id })
|
||||
const book = await Database.bookModel.create({
|
||||
title: 'And Now, Back to You',
|
||||
audioFiles: [],
|
||||
tags: [],
|
||||
narrators: [],
|
||||
genres: [],
|
||||
chapters: []
|
||||
})
|
||||
await Database.libraryItemModel.create({
|
||||
libraryFiles: [],
|
||||
mediaId: book.id,
|
||||
mediaType: 'book',
|
||||
libraryId: library.id,
|
||||
libraryFolderId: libraryFolder.id
|
||||
})
|
||||
|
||||
const results = await libraryItemsBookFilters.search(null, library, 'And Now Back to You', 10, 0)
|
||||
|
||||
expect(results.book).to.have.length(1)
|
||||
expect(results.book[0].libraryItem.media.metadata.title).to.equal('And Now, Back to You')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue