mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Fix LibraryItemController unit test
This commit is contained in:
parent
4787e7fdb5
commit
eb853d9f09
@ -1144,7 +1144,7 @@ class LibraryItemController {
|
|||||||
*/
|
*/
|
||||||
async middleware(req, res, next) {
|
async middleware(req, res, next) {
|
||||||
req.libraryItem = await Database.libraryItemModel.getExpandedById(req.params.id)
|
req.libraryItem = await Database.libraryItemModel.getExpandedById(req.params.id)
|
||||||
req.oldLibraryItem = await Database.libraryItemModel.getOldLibraryItem(req.libraryItem)
|
req.oldLibraryItem = Database.libraryItemModel.getOldLibraryItem(req.libraryItem)
|
||||||
if (!req.libraryItem?.media) return res.sendStatus(404)
|
if (!req.libraryItem?.media) return res.sendStatus(404)
|
||||||
|
|
||||||
// Check user can access this library item
|
// Check user can access this library item
|
||||||
|
@ -82,11 +82,13 @@ describe('LibraryItemController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should remove authors and series with no books on library item delete', async () => {
|
it('should remove authors and series with no books on library item delete', async () => {
|
||||||
const oldLibraryItem = await Database.libraryItemModel.getOldById(libraryItem1Id)
|
const libraryItem = await Database.libraryItemModel.getExpandedById(libraryItem1Id)
|
||||||
|
const oldLibraryItem = Database.libraryItemModel.getOldLibraryItem(libraryItem)
|
||||||
|
|
||||||
const fakeReq = {
|
const fakeReq = {
|
||||||
query: {},
|
query: {},
|
||||||
libraryItem: oldLibraryItem
|
libraryItem,
|
||||||
|
oldLibraryItem
|
||||||
}
|
}
|
||||||
const fakeRes = {
|
const fakeRes = {
|
||||||
sendStatus: sinon.spy()
|
sendStatus: sinon.spy()
|
||||||
@ -156,7 +158,8 @@ describe('LibraryItemController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should remove authors and series with no books on library item update media', async () => {
|
it('should remove authors and series with no books on library item update media', async () => {
|
||||||
const oldLibraryItem = await Database.libraryItemModel.getOldById(libraryItem1Id)
|
const libraryItem = await Database.libraryItemModel.getExpandedById(libraryItem1Id)
|
||||||
|
const oldLibraryItem = Database.libraryItemModel.getOldLibraryItem(libraryItem)
|
||||||
|
|
||||||
// Update library item 1 remove all authors and series
|
// Update library item 1 remove all authors and series
|
||||||
const fakeReq = {
|
const fakeReq = {
|
||||||
@ -167,7 +170,8 @@ describe('LibraryItemController', () => {
|
|||||||
series: []
|
series: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
libraryItem: oldLibraryItem
|
libraryItem,
|
||||||
|
oldLibraryItem
|
||||||
}
|
}
|
||||||
const fakeRes = {
|
const fakeRes = {
|
||||||
json: sinon.spy()
|
json: sinon.spy()
|
||||||
|
Loading…
Reference in New Issue
Block a user