mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-13 06:51:29 +00:00
Fix Smart Speed playback time contract
This commit is contained in:
parent
5c747a7f8f
commit
97c5d6341e
9 changed files with 205 additions and 17 deletions
26
test/server/objects/PlaybackSession.test.js
Normal file
26
test/server/objects/PlaybackSession.test.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const { expect } = require('chai')
|
||||
|
||||
const PlaybackSession = require('../../../server/objects/PlaybackSession')
|
||||
|
||||
describe('PlaybackSession', () => {
|
||||
it('computes progress from a single currentTime and duration domain', () => {
|
||||
const session = new PlaybackSession({
|
||||
id: 'session-1',
|
||||
userId: 'user-1',
|
||||
libraryItemId: 'item-1',
|
||||
mediaType: 'book',
|
||||
duration: 10,
|
||||
currentTime: 6,
|
||||
startedAt: Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
deviceInfo: {}
|
||||
})
|
||||
|
||||
expect(session.progress).to.equal(0.6)
|
||||
expect(session.mediaProgressObject).to.include({
|
||||
duration: 10,
|
||||
currentTime: 6,
|
||||
progress: 0.6
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue