Improve create transcoding jobs tests

This commit is contained in:
Chocobozzz 2018-05-30 11:11:51 +02:00
parent 0c948c1659
commit 04bf312cda
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 18 additions and 3 deletions

View File

@ -50,7 +50,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
return fallbackToMediaSource() return fallbackToMediaSource()
}) })
preparedElem.addEventListener('loadstart', onLoadStart) preparedElem.addEventListener('canplay', onLoadStart)
return videostream(file, preparedElem) return videostream(file, preparedElem)
} }
@ -66,7 +66,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
return callback(err) return callback(err)
}) })
preparedElem.addEventListener('loadstart', onLoadStart) preparedElem.addEventListener('canplay', onLoadStart)
const wrapper = new MediaElementWrapper(preparedElem) const wrapper = new MediaElementWrapper(preparedElem)
const writable = wrapper.createWriteStream(codecs) const writable = wrapper.createWriteStream(codecs)
@ -95,7 +95,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
} }
function onLoadStart () { function onLoadStart () {
preparedElem.removeEventListener('loadstart', onLoadStart) preparedElem.removeEventListener('canplay', onLoadStart)
if (opts.autoplay) preparedElem.play() if (opts.autoplay) preparedElem.play()
callback(null, renderer) callback(null, renderer)

View File

@ -72,12 +72,27 @@ describe('Test create transcoding jobs', function () {
const videos = res.body.data const videos = res.body.data
expect(videos).to.have.lengthOf(2) expect(videos).to.have.lengthOf(2)
let infoHashes: { [ id: number ]: string }
for (const video of videos) { for (const video of videos) {
const res2 = await getVideo(server.url, video.uuid) const res2 = await getVideo(server.url, video.uuid)
const videoDetail: VideoDetails = res2.body const videoDetail: VideoDetails = res2.body
if (video.uuid === video2UUID) { if (video.uuid === video2UUID) {
expect(videoDetail.files).to.have.lengthOf(4) expect(videoDetail.files).to.have.lengthOf(4)
if (!infoHashes) {
infoHashes = {}
for (const file of videoDetail.files) {
infoHashes[file.resolution.id.toString()] = file.magnetUri
}
} else {
for (const resolution of Object.keys(infoHashes)) {
const file = videoDetail.files.find(f => f.resolution.id.toString() === resolution)
expect(file.magnetUri).to.equal(infoHashes[resolution])
}
}
} else { } else {
expect(videoDetail.files).to.have.lengthOf(1) expect(videoDetail.files).to.have.lengthOf(1)
} }