Commit 8b06916e by Anto Stupak Committed by Vasyl Nakvasiuk

Fix tests for firefox

parent 7eb18fe0
...@@ -55,12 +55,11 @@ describe 'VideoCaption', -> ...@@ -55,12 +55,11 @@ describe 'VideoCaption', ->
@caption = @player.caption @caption = @player.caption
it 'render the caption', -> it 'render the caption', ->
expect($('.subtitles').html()).toMatch new RegExp(''' captionsData = jasmine.stubbedCaption
<li data-index="0" data-start="0">Caption at 0</li> $('.subtitles li[data-index]').each (index, link) =>
<li data-index="1" data-start="10000">Caption at 10000</li> expect($(link)).toHaveData 'index', index
<li data-index="2" data-start="20000">Caption at 20000</li> expect($(link)).toHaveData 'start', captionsData.start[index]
<li data-index="3" data-start="30000">Caption at 30000</li> expect($(link)).toHaveText captionsData.text[index]
'''.replace(/\n/g, ''))
it 'add a padding element to caption', -> it 'add a padding element to caption', ->
expect($('.subtitles li:first')).toBe '.spacing' expect($('.subtitles li:first')).toBe '.spacing'
...@@ -179,12 +178,11 @@ describe 'VideoCaption', -> ...@@ -179,12 +178,11 @@ describe 'VideoCaption', ->
@caption.play() @caption.play()
it 'render the caption', -> it 'render the caption', ->
expect($('.subtitles').html()).toMatch new RegExp( captionsData = jasmine.stubbedCaption
'''<li data-index="0" data-start="0">Caption at 0</li>''' + $('.subtitles li[data-index]').each (index, link) =>
'''<li data-index="1" data-start="10000">Caption at 10000</li>''' + expect($(link)).toHaveData 'index', index
'''<li data-index="2" data-start="20000">Caption at 20000</li>''' + expect($(link)).toHaveData 'start', captionsData.start[index]
'''<li data-index="3" data-start="30000">Caption at 30000</li>''' expect($(link)).toHaveText captionsData.text[index]
)
it 'add a padding element to caption', -> it 'add a padding element to caption', ->
expect($('.subtitles li:first')).toBe '.spacing' expect($('.subtitles li:first')).toBe '.spacing'
...@@ -268,13 +266,12 @@ describe 'VideoCaption', -> ...@@ -268,13 +266,12 @@ describe 'VideoCaption', ->
@caption.resize() @caption.resize()
it 'set the height of caption container', -> it 'set the height of caption container', ->
expect(parseInt($('.subtitles').css('maxHeight'))).toBeCloseTo $('.video-wrapper').height(), 5 expect(parseInt($('.subtitles').css('maxHeight'))).toBeCloseTo $('.video-wrapper').height(), 2
it 'set the height of caption spacing', -> it 'set the height of caption spacing', ->
expect(parseInt($('.subtitles .spacing:first').css('height'))).toEqual( expect(Math.abs(parseInt($('.subtitles .spacing:first').css('height')) - @caption.topSpacingHeight())).toBeLessThan 1
$('.video-wrapper').height() / 2 - $('.subtitles li:not(.spacing):first').height() / 2) expect(Math.abs(parseInt($('.subtitles .spacing:last').css('height')) - @caption.bottomSpacingHeight())).toBeLessThan 1
expect(parseInt($('.subtitles .spacing:last').css('height'))).toEqual(
$('.video-wrapper').height() / 2 - $('.subtitles li:not(.spacing):last').height() / 2)
it 'scroll caption to new position', -> it 'scroll caption to new position', ->
expect($.fn.scrollTo).toHaveBeenCalled() expect($.fn.scrollTo).toHaveBeenCalled()
......
...@@ -86,7 +86,7 @@ describe 'VideoPlayer', -> ...@@ -86,7 +86,7 @@ describe 'VideoPlayer', ->
expect($(@player.volumeControl)).toHandleWith 'volumeChange', @player.onVolumeChange expect($(@player.volumeControl)).toHandleWith 'volumeChange', @player.onVolumeChange
it 'bind to key press', -> it 'bind to key press', ->
expect($(document)).toHandleWith 'keyup', @player.bindExitFullScreen expect($(document.documentElement)).toHandleWith 'keyup', @player.bindExitFullScreen
it 'bind to fullscreen switching button', -> it 'bind to fullscreen switching button', ->
expect($('.add-fullscreen')).toHandleWith 'click', @player.toggleFullScreen expect($('.add-fullscreen')).toHandleWith 'click', @player.toggleFullScreen
......
...@@ -10,15 +10,16 @@ describe 'VideoSpeedControl', -> ...@@ -10,15 +10,16 @@ describe 'VideoSpeedControl', ->
@speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0' @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
it 'add the video speed control to player', -> it 'add the video speed control to player', ->
expect($('.secondary-controls').html()).toContain ''' secondaryControls = $('.secondary-controls')
<div class="speeds"> li = secondaryControls.find('.video_speeds li')
<a href="#"> expect(secondaryControls).toContain '.speeds'
<h3>Speed</h3> expect(secondaryControls).toContain '.video_speeds'
<p class="active">1.0x</p> expect(secondaryControls.find('p.active').text()).toBe '1.0x'
</a> expect(li.filter('.active')).toHaveData 'speed', @speedControl.currentSpeed
<ol class="video_speeds"><li data-speed="1.0" class="active"><a href="#">1.0x</a></li><li data-speed="0.75"><a href="#">0.75x</a></li></ol> expect(li.length).toBe @speedControl.speeds.length
</div> $.each li.toArray().reverse(), (index, link) =>
''' expect($(link)).toHaveData 'speed', @speedControl.speeds[index]
expect($(link).find('a').text()).toBe @speedControl.speeds[index] + 'x'
it 'bind to change video speed link', -> it 'bind to change video speed link', ->
expect($('.video_speeds a')).toHandleWith 'click', @speedControl.changeVideoSpeed expect($('.video_speeds a')).toHandleWith 'click', @speedControl.changeVideoSpeed
......
...@@ -15,7 +15,7 @@ class @VideoPlayer extends Subview ...@@ -15,7 +15,7 @@ class @VideoPlayer extends Subview
$(@progressSlider).bind('seek', @onSeek) $(@progressSlider).bind('seek', @onSeek)
if @volumeControl if @volumeControl
$(@volumeControl).bind('volumeChange', @onVolumeChange) $(@volumeControl).bind('volumeChange', @onVolumeChange)
$(document).keyup @bindExitFullScreen $(document.documentElement).keyup @bindExitFullScreen
@$('.add-fullscreen').click @toggleFullScreen @$('.add-fullscreen').click @toggleFullScreen
@addToolTip() unless onTouchBasedDevice() @addToolTip() unless onTouchBasedDevice()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment