import { calculateChapterStyles } from '..'

const videoDuration = 60000

it('return correct progress and width lengthes', () => {
  let chapter = {
    duration: 15000,
    endMs: 20000,
    period: 0,
    startMs: 5000,
    urls: {},
  }
  let expected = {
    ...chapter,
    loaded: 100,
    played: 100,
    width: 25,
  }
  expect(calculateChapterStyles({
    activeChapterIndex: 0,
    chapters: [chapter],
    loadedProgress: 30000,
    playedProgress: 30000,
    videoDuration,
  })).toEqual([expected])

  chapter = {
    duration: 30000,
    endMs: 30000,
    period: 0,
    startMs: 0,
    urls: {},
  }
  expected = {
    ...chapter,
    loaded: 50,
    played: 50,
    width: 50,
  }
  expect(calculateChapterStyles({
    activeChapterIndex: 0,
    chapters: [chapter],
    loadedProgress: 15000,
    playedProgress: 15000,
    videoDuration,
  })).toEqual([expected])
})
