Skip to content
Snippets Groups Projects
Commit 47409654 authored by cahrens's avatar cahrens
Browse files

Skip tests instead of commenting them out (for merge that is coming).

parent 05428f5b
No related merge requests found
......@@ -70,12 +70,12 @@ describe 'Problem', ->
it 'bind the math input', ->
expect($('input.math')).toHandleWith 'keyup', @problem.refreshMath
# TODO figure out why this is failing
# it 'replace math content on the page', ->
# expect(MathJax.Hub.Queue.mostRecentCall.args).toEqual [
# ['Text', @stubbedJax, ''],
# [@problem.updateMathML, @stubbedJax, $('#input_example_1').get(0)]
# ]
# TODO: figure out why failing
xit 'replace math content on the page', ->
expect(MathJax.Hub.Queue.mostRecentCall.args).toEqual [
['Text', @stubbedJax, ''],
[@problem.updateMathML, @stubbedJax, $('#input_example_1').get(0)]
]
describe 'render', ->
beforeEach ->
......@@ -138,14 +138,14 @@ describe 'Problem', ->
@problem.check()
expect(@problem.el.html()).toEqual 'Incorrect!'
# TODO figure out why this is failing
# describe 'when the response is undetermined', ->
# it 'alert the response', ->
# spyOn window, 'alert'
# spyOn($, 'postWithPrefix').andCallFake (url, answers, callback) ->
# callback(success: 'Number Only!')
# @problem.check()
# expect(window.alert).toHaveBeenCalledWith 'Number Only!'
# TODO: figure out why failing
xdescribe 'when the response is undetermined', ->
it 'alert the response', ->
spyOn window, 'alert'
spyOn($, 'postWithPrefix').andCallFake (url, answers, callback) ->
callback(success: 'Number Only!')
@problem.check()
expect(window.alert).toHaveBeenCalledWith 'Number Only!'
describe 'reset', ->
beforeEach ->
......@@ -264,12 +264,12 @@ describe 'Problem', ->
expect($.postWithPrefix).toHaveBeenCalledWith '/problem/Problem1/problem_save',
'foo=1&bar=2', jasmine.any(Function)
# TODO figure out why this is failing
# it 'alert to the user', ->
# spyOn window, 'alert'
# spyOn($, 'postWithPrefix').andCallFake (url, answers, callback) -> callback(success: 'OK')
# @problem.save()
# expect(window.alert).toHaveBeenCalledWith 'Saved'
# TODO: figure out why failing
xit 'alert to the user', ->
spyOn window, 'alert'
spyOn($, 'postWithPrefix').andCallFake (url, answers, callback) -> callback(success: 'OK')
@problem.save()
expect(window.alert).toHaveBeenCalledWith 'Saved'
describe 'refreshMath', ->
beforeEach ->
......@@ -323,10 +323,10 @@ describe 'Problem', ->
@problem.refreshAnswers()
expect(@stubCodeMirror.save).toHaveBeenCalled()
# TODO figure out why this is failing
# it 'serialize all answers', ->
# @problem.refreshAnswers()
# expect(@problem.answers).toEqual "input_1_1=one&input_1_2=two"
# TODO: figure out why failing
xit 'serialize all answers', ->
@problem.refreshAnswers()
expect(@problem.answers).toEqual "input_1_1=one&input_1_2=two"
#describe 'Sequence', ->
# beforeEach ->
# # Stub MathJax
# window.MathJax = { Hub: { Queue: -> } }
# spyOn Logger, 'log'
#
# loadFixtures 'sequence.html'
# @items = $.parseJSON readFixtures('items.json')
#
# describe 'constructor', ->
# beforeEach ->
# @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 1
#
# it 'set the element', ->
# expect(@sequence.el).toEqual $('#sequence_1')
#
# it 'build the navigation', ->
# classes = $('#sequence-list li>a').map(-> $(this).attr('class')).get()
# elements = $('#sequence-list li>a').map(-> $(this).attr('data-element')).get()
# titles = $('#sequence-list li>a>p').map(-> $(this).html()).get()
#
# expect(classes).toEqual ['seq_video_active', 'seq_video_inactive', 'seq_problem_inactive']
# expect(elements).toEqual ['1', '2', '3']
# expect(titles).toEqual ['Video 1', 'Video 2', 'Sample Problem']
#
# it 'bind the page events', ->
# expect($('#sequence-list a')).toHandleWith 'click', @sequence.goto
#
# it 'render the active sequence content', ->
# expect($('#seq_content').html()).toEqual 'Video 1'
#
# describe 'toggleArrows', ->
# beforeEach ->
# @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 1
#
# describe 'when the first tab is active', ->
# beforeEach ->
# @sequence.position = 1
# @sequence.toggleArrows()
#
# it 'disable the previous button', ->
# expect($('.sequence-nav-buttons .prev a')).toHaveClass 'disabled'
#
# it 'enable the next button', ->
# expect($('.sequence-nav-buttons .next a')).not.toHaveClass 'disabled'
# expect($('.sequence-nav-buttons .next a')).toHandleWith 'click', @sequence.next
#
# describe 'when the middle tab is active', ->
# beforeEach ->
# @sequence.position = 2
# @sequence.toggleArrows()
#
# it 'enable the previous button', ->
# expect($('.sequence-nav-buttons .prev a')).not.toHaveClass 'disabled'
# expect($('.sequence-nav-buttons .prev a')).toHandleWith 'click', @sequence.previous
#
# it 'enable the next button', ->
# expect($('.sequence-nav-buttons .next a')).not.toHaveClass 'disabled'
# expect($('.sequence-nav-buttons .next a')).toHandleWith 'click', @sequence.next
#
# describe 'when the last tab is active', ->
# beforeEach ->
# @sequence.position = 3
# @sequence.toggleArrows()
#
# it 'enable the previous button', ->
# expect($('.sequence-nav-buttons .prev a')).not.toHaveClass 'disabled'
# expect($('.sequence-nav-buttons .prev a')).toHandleWith 'click', @sequence.previous
#
# it 'disable the next button', ->
# expect($('.sequence-nav-buttons .next a')).toHaveClass 'disabled'
#
# describe 'render', ->
# beforeEach ->
# spyOn $, 'postWithPrefix'
# @sequence = new Sequence '1', 'sequence_1', @items, 'sequence'
# spyOnEvent @sequence.el, 'contentChanged'
# spyOn(@sequence, 'toggleArrows').andCallThrough()
#
# describe 'with a different position than the current one', ->
# beforeEach ->
# @sequence.render 1
#
# describe 'with no previous position', ->
# it 'does not save the new position', ->
# expect($.postWithPrefix).not.toHaveBeenCalled()
#
# describe 'with previous position', ->
# beforeEach ->
# @sequence.position = 2
# @sequence.render 1
#
# it 'mark the previous tab as visited', ->
# expect($('[data-element="2"]')).toHaveClass 'seq_video_visited'
#
# it 'save the new position', ->
# expect($.postWithPrefix).toHaveBeenCalledWith '/modx/1/goto_position', position: 1
#
# it 'mark new tab as active', ->
# expect($('[data-element="1"]')).toHaveClass 'seq_video_active'
#
# it 'render the new content', ->
# expect($('#seq_content').html()).toEqual 'Video 1'
#
# it 'update the position', ->
# expect(@sequence.position).toEqual 1
#
# it 're-update the arrows', ->
# expect(@sequence.toggleArrows).toHaveBeenCalled()
#
# it 'trigger contentChanged event', ->
# expect('contentChanged').toHaveBeenTriggeredOn @sequence.el
#
# describe 'with the same position as the current one', ->
# it 'should not trigger contentChanged event', ->
# @sequence.position = 2
# @sequence.render 2
# expect('contentChanged').not.toHaveBeenTriggeredOn @sequence.el
#
# describe 'goto', ->
# beforeEach ->
# jasmine.stubRequests()
# @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
# $('[data-element="3"]').click()
#
# it 'log the sequence goto event', ->
# expect(Logger.log).toHaveBeenCalledWith 'seq_goto', old: 2, new: 3, id: '1'
#
# it 'call render on the right sequence', ->
# expect($('#seq_content').html()).toEqual 'Sample Problem'
#
# describe 'next', ->
# beforeEach ->
# jasmine.stubRequests()
# @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
# $('.sequence-nav-buttons .next a').click()
#
# it 'log the next sequence event', ->
# expect(Logger.log).toHaveBeenCalledWith 'seq_next', old: 2, new: 3, id: '1'
#
# it 'call render on the next sequence', ->
# expect($('#seq_content').html()).toEqual 'Sample Problem'
#
# describe 'previous', ->
# beforeEach ->
# jasmine.stubRequests()
# @sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
# $('.sequence-nav-buttons .prev a').click()
#
# it 'log the previous sequence event', ->
# expect(Logger.log).toHaveBeenCalledWith 'seq_prev', old: 2, new: 1, id: '1'
#
# it 'call render on the previous sequence', ->
# expect($('#seq_content').html()).toEqual 'Video 1'
#
# describe 'link_for', ->
# it 'return a link for specific position', ->
# sequence = new Sequence '1', 'sequence_1', @items, 2
# expect(sequence.link_for(2)).toBe '[data-element="2"]'
# TODO: figure out why failing
xdescribe 'Sequence', ->
beforeEach ->
# Stub MathJax
window.MathJax = { Hub: { Queue: -> } }
spyOn Logger, 'log'
loadFixtures 'sequence.html'
@items = $.parseJSON readFixtures('items.json')
describe 'constructor', ->
beforeEach ->
@sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 1
it 'set the element', ->
expect(@sequence.el).toEqual $('#sequence_1')
it 'build the navigation', ->
classes = $('#sequence-list li>a').map(-> $(this).attr('class')).get()
elements = $('#sequence-list li>a').map(-> $(this).attr('data-element')).get()
titles = $('#sequence-list li>a>p').map(-> $(this).html()).get()
expect(classes).toEqual ['seq_video_active', 'seq_video_inactive', 'seq_problem_inactive']
expect(elements).toEqual ['1', '2', '3']
expect(titles).toEqual ['Video 1', 'Video 2', 'Sample Problem']
it 'bind the page events', ->
expect($('#sequence-list a')).toHandleWith 'click', @sequence.goto
it 'render the active sequence content', ->
expect($('#seq_content').html()).toEqual 'Video 1'
describe 'toggleArrows', ->
beforeEach ->
@sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 1
describe 'when the first tab is active', ->
beforeEach ->
@sequence.position = 1
@sequence.toggleArrows()
it 'disable the previous button', ->
expect($('.sequence-nav-buttons .prev a')).toHaveClass 'disabled'
it 'enable the next button', ->
expect($('.sequence-nav-buttons .next a')).not.toHaveClass 'disabled'
expect($('.sequence-nav-buttons .next a')).toHandleWith 'click', @sequence.next
describe 'when the middle tab is active', ->
beforeEach ->
@sequence.position = 2
@sequence.toggleArrows()
it 'enable the previous button', ->
expect($('.sequence-nav-buttons .prev a')).not.toHaveClass 'disabled'
expect($('.sequence-nav-buttons .prev a')).toHandleWith 'click', @sequence.previous
it 'enable the next button', ->
expect($('.sequence-nav-buttons .next a')).not.toHaveClass 'disabled'
expect($('.sequence-nav-buttons .next a')).toHandleWith 'click', @sequence.next
describe 'when the last tab is active', ->
beforeEach ->
@sequence.position = 3
@sequence.toggleArrows()
it 'enable the previous button', ->
expect($('.sequence-nav-buttons .prev a')).not.toHaveClass 'disabled'
expect($('.sequence-nav-buttons .prev a')).toHandleWith 'click', @sequence.previous
it 'disable the next button', ->
expect($('.sequence-nav-buttons .next a')).toHaveClass 'disabled'
describe 'render', ->
beforeEach ->
spyOn $, 'postWithPrefix'
@sequence = new Sequence '1', 'sequence_1', @items, 'sequence'
spyOnEvent @sequence.el, 'contentChanged'
spyOn(@sequence, 'toggleArrows').andCallThrough()
describe 'with a different position than the current one', ->
beforeEach ->
@sequence.render 1
describe 'with no previous position', ->
it 'does not save the new position', ->
expect($.postWithPrefix).not.toHaveBeenCalled()
describe 'with previous position', ->
beforeEach ->
@sequence.position = 2
@sequence.render 1
it 'mark the previous tab as visited', ->
expect($('[data-element="2"]')).toHaveClass 'seq_video_visited'
it 'save the new position', ->
expect($.postWithPrefix).toHaveBeenCalledWith '/modx/1/goto_position', position: 1
it 'mark new tab as active', ->
expect($('[data-element="1"]')).toHaveClass 'seq_video_active'
it 'render the new content', ->
expect($('#seq_content').html()).toEqual 'Video 1'
it 'update the position', ->
expect(@sequence.position).toEqual 1
it 're-update the arrows', ->
expect(@sequence.toggleArrows).toHaveBeenCalled()
it 'trigger contentChanged event', ->
expect('contentChanged').toHaveBeenTriggeredOn @sequence.el
describe 'with the same position as the current one', ->
it 'should not trigger contentChanged event', ->
@sequence.position = 2
@sequence.render 2
expect('contentChanged').not.toHaveBeenTriggeredOn @sequence.el
describe 'goto', ->
beforeEach ->
jasmine.stubRequests()
@sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
$('[data-element="3"]').click()
it 'log the sequence goto event', ->
expect(Logger.log).toHaveBeenCalledWith 'seq_goto', old: 2, new: 3, id: '1'
it 'call render on the right sequence', ->
expect($('#seq_content').html()).toEqual 'Sample Problem'
describe 'next', ->
beforeEach ->
jasmine.stubRequests()
@sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
$('.sequence-nav-buttons .next a').click()
it 'log the next sequence event', ->
expect(Logger.log).toHaveBeenCalledWith 'seq_next', old: 2, new: 3, id: '1'
it 'call render on the next sequence', ->
expect($('#seq_content').html()).toEqual 'Sample Problem'
describe 'previous', ->
beforeEach ->
jasmine.stubRequests()
@sequence = new Sequence '1', 'sequence_1', @items, 'sequence', 2
$('.sequence-nav-buttons .prev a').click()
it 'log the previous sequence event', ->
expect(Logger.log).toHaveBeenCalledWith 'seq_prev', old: 2, new: 1, id: '1'
it 'call render on the previous sequence', ->
expect($('#seq_content').html()).toEqual 'Video 1'
describe 'link_for', ->
it 'return a link for specific position', ->
sequence = new Sequence '1', 'sequence_1', @items, 2
expect(sequence.link_for(2)).toBe '[data-element="2"]'
#describe 'VideoControl', ->
# beforeEach ->
# jasmine.stubVideoPlayer @
# $('.video-controls').html ''
#
# describe 'constructor', ->
# it 'render the video controls', ->
# new VideoControl(el: $('.video-controls'))
# expect($('.video-controls').html()).toContain '''
# <div class="slider"></div>
# <div>
# <ul class="vcr">
# <li><a class="video_control play" href="#">Play</a></li>
# <li>
# <div class="vidtime">0:00 / 0:00</div>
# </li>
# </ul>
# <div class="secondary-controls">
# <a href="#" class="add-fullscreen" title="Fill browser">Fill Browser</a>
# </div>
# </div>
# '''
#
# it 'bind the playback button', ->
# control = new VideoControl(el: $('.video-controls'))
# expect($('.video_control')).toHandleWith 'click', control.togglePlayback
#
# describe 'when on a touch based device', ->
# beforeEach ->
# spyOn(window, 'onTouchBasedDevice').andReturn true
#
# it 'does not add the play class to video control', ->
# new VideoControl(el: $('.video-controls'))
# expect($('.video_control')).not.toHaveClass 'play'
# expect($('.video_control')).not.toHaveHtml 'Play'
#
#
# describe 'when on a non-touch based device', ->
# beforeEach ->
# spyOn(window, 'onTouchBasedDevice').andReturn false
#
# it 'add the play class to video control', ->
# new VideoControl(el: $('.video-controls'))
# expect($('.video_control')).toHaveClass 'play'
# expect($('.video_control')).toHaveHtml 'Play'
#
# describe 'play', ->
# beforeEach ->
# @control = new VideoControl(el: $('.video-controls'))
# @control.play()
#
# it 'switch playback button to play state', ->
# expect($('.video_control')).not.toHaveClass 'play'
# expect($('.video_control')).toHaveClass 'pause'
# expect($('.video_control')).toHaveHtml 'Pause'
#
# describe 'pause', ->
# beforeEach ->
# @control = new VideoControl(el: $('.video-controls'))
# @control.pause()
#
# it 'switch playback button to pause state', ->
# expect($('.video_control')).not.toHaveClass 'pause'
# expect($('.video_control')).toHaveClass 'play'
# expect($('.video_control')).toHaveHtml 'Play'
#
# describe 'togglePlayback', ->
# beforeEach ->
# @control = new VideoControl(el: $('.video-controls'))
#
# describe 'when the control does not have play or pause class', ->
# beforeEach ->
# $('.video_control').removeClass('play').removeClass('pause')
#
# describe 'when the video is playing', ->
# beforeEach ->
# $('.video_control').addClass('play')
# spyOnEvent @control, 'pause'
# @control.togglePlayback jQuery.Event('click')
#
# it 'does not trigger the pause event', ->
# expect('pause').not.toHaveBeenTriggeredOn @control
#
# describe 'when the video is paused', ->
# beforeEach ->
# $('.video_control').addClass('pause')
# spyOnEvent @control, 'play'
# @control.togglePlayback jQuery.Event('click')
#
# it 'does not trigger the play event', ->
# expect('play').not.toHaveBeenTriggeredOn @control
#
# describe 'when the video is playing', ->
# beforeEach ->
# spyOnEvent @control, 'pause'
# $('.video_control').addClass 'pause'
# @control.togglePlayback jQuery.Event('click')
#
# it 'trigger the pause event', ->
# expect('pause').toHaveBeenTriggeredOn @control
#
# describe 'when the video is paused', ->
# beforeEach ->
# spyOnEvent @control, 'play'
# $('.video_control').addClass 'play'
# @control.togglePlayback jQuery.Event('click')
#
# it 'trigger the play event', ->
# expect('play').toHaveBeenTriggeredOn @control
# TODO: figure out why failing
xdescribe 'VideoControl', ->
beforeEach ->
jasmine.stubVideoPlayer @
$('.video-controls').html ''
describe 'constructor', ->
it 'render the video controls', ->
new VideoControl(el: $('.video-controls'))
expect($('.video-controls').html()).toContain '''
<div class="slider"></div>
<div>
<ul class="vcr">
<li><a class="video_control play" href="#">Play</a></li>
<li>
<div class="vidtime">0:00 / 0:00</div>
</li>
</ul>
<div class="secondary-controls">
<a href="#" class="add-fullscreen" title="Fill browser">Fill Browser</a>
</div>
</div>
'''
it 'bind the playback button', ->
control = new VideoControl(el: $('.video-controls'))
expect($('.video_control')).toHandleWith 'click', control.togglePlayback
describe 'when on a touch based device', ->
beforeEach ->
spyOn(window, 'onTouchBasedDevice').andReturn true
it 'does not add the play class to video control', ->
new VideoControl(el: $('.video-controls'))
expect($('.video_control')).not.toHaveClass 'play'
expect($('.video_control')).not.toHaveHtml 'Play'
describe 'when on a non-touch based device', ->
beforeEach ->
spyOn(window, 'onTouchBasedDevice').andReturn false
it 'add the play class to video control', ->
new VideoControl(el: $('.video-controls'))
expect($('.video_control')).toHaveClass 'play'
expect($('.video_control')).toHaveHtml 'Play'
describe 'play', ->
beforeEach ->
@control = new VideoControl(el: $('.video-controls'))
@control.play()
it 'switch playback button to play state', ->
expect($('.video_control')).not.toHaveClass 'play'
expect($('.video_control')).toHaveClass 'pause'
expect($('.video_control')).toHaveHtml 'Pause'
describe 'pause', ->
beforeEach ->
@control = new VideoControl(el: $('.video-controls'))
@control.pause()
it 'switch playback button to pause state', ->
expect($('.video_control')).not.toHaveClass 'pause'
expect($('.video_control')).toHaveClass 'play'
expect($('.video_control')).toHaveHtml 'Play'
describe 'togglePlayback', ->
beforeEach ->
@control = new VideoControl(el: $('.video-controls'))
describe 'when the control does not have play or pause class', ->
beforeEach ->
$('.video_control').removeClass('play').removeClass('pause')
describe 'when the video is playing', ->
beforeEach ->
$('.video_control').addClass('play')
spyOnEvent @control, 'pause'
@control.togglePlayback jQuery.Event('click')
it 'does not trigger the pause event', ->
expect('pause').not.toHaveBeenTriggeredOn @control
describe 'when the video is paused', ->
beforeEach ->
$('.video_control').addClass('pause')
spyOnEvent @control, 'play'
@control.togglePlayback jQuery.Event('click')
it 'does not trigger the play event', ->
expect('play').not.toHaveBeenTriggeredOn @control
describe 'when the video is playing', ->
beforeEach ->
spyOnEvent @control, 'pause'
$('.video_control').addClass 'pause'
@control.togglePlayback jQuery.Event('click')
it 'trigger the pause event', ->
expect('pause').toHaveBeenTriggeredOn @control
describe 'when the video is paused', ->
beforeEach ->
spyOnEvent @control, 'play'
$('.video_control').addClass 'play'
@control.togglePlayback jQuery.Event('click')
it 'trigger the play event', ->
expect('play').toHaveBeenTriggeredOn @control
#describe 'VideoProgressSlider', ->
# beforeEach ->
# jasmine.stubVideoPlayer @
#
# describe 'constructor', ->
# describe 'on a non-touch based device', ->
# beforeEach ->
# spyOn($.fn, 'slider').andCallThrough()
# spyOn(window, 'onTouchBasedDevice').andReturn false
# @slider = new VideoProgressSlider el: $('.slider')
#
# it 'build the slider', ->
# expect(@slider.slider).toBe '.slider'
# expect($.fn.slider).toHaveBeenCalledWith
# range: 'min'
# change: @slider.onChange
# slide: @slider.onSlide
# stop: @slider.onStop
#
# it 'build the seek handle', ->
# expect(@slider.handle).toBe '.slider .ui-slider-handle'
# expect($.fn.qtip).toHaveBeenCalledWith
# content: "0:00"
# position:
# my: 'bottom center'
# at: 'top center'
# container: @slider.handle
# hide:
# delay: 700
# style:
# classes: 'ui-tooltip-slider'
# widget: true
#
# describe 'on a touch-based device', ->
# beforeEach ->
# spyOn($.fn, 'slider').andCallThrough()
# spyOn(window, 'onTouchBasedDevice').andReturn true
# @slider = new VideoProgressSlider el: $('.slider')
#
# it 'does not build the slider', ->
# expect(@slider.slider).toBeUndefined
# expect($.fn.slider).not.toHaveBeenCalled()
#
# describe 'play', ->
# beforeEach ->
# @slider = new VideoProgressSlider el: $('.slider')
# spyOn($.fn, 'slider').andCallThrough()
#
# describe 'when the slider was already built', ->
# beforeEach ->
# @slider.play()
#
# it 'does not build the slider', ->
# expect($.fn.slider).not.toHaveBeenCalled
#
# describe 'when the slider was not already built', ->
# beforeEach ->
# @slider.slider = null
# @slider.play()
#
# it 'build the slider', ->
# expect(@slider.slider).toBe '.slider'
# expect($.fn.slider).toHaveBeenCalledWith
# range: 'min'
# change: @slider.onChange
# slide: @slider.onSlide
# stop: @slider.onStop
#
# it 'build the seek handle', ->
# expect(@slider.handle).toBe '.ui-slider-handle'
# expect($.fn.qtip).toHaveBeenCalledWith
# content: "0:00"
# position:
# my: 'bottom center'
# at: 'top center'
# container: @slider.handle
# hide:
# delay: 700
# style:
# classes: 'ui-tooltip-slider'
# widget: true
#
# describe 'updatePlayTime', ->
# beforeEach ->
# @slider = new VideoProgressSlider el: $('.slider')
# spyOn($.fn, 'slider').andCallThrough()
#
# describe 'when frozen', ->
# beforeEach ->
# @slider.frozen = true
# @slider.updatePlayTime 20, 120
#
# it 'does not update the slider', ->
# expect($.fn.slider).not.toHaveBeenCalled()
#
# describe 'when not frozen', ->
# beforeEach ->
# @slider.frozen = false
# @slider.updatePlayTime 20, 120
#
# it 'update the max value of the slider', ->
# expect($.fn.slider).toHaveBeenCalledWith 'option', 'max', 120
#
# it 'update current value of the slider', ->
# expect($.fn.slider).toHaveBeenCalledWith 'value', 20
#
# describe 'onSlide', ->
# beforeEach ->
# @slider = new VideoProgressSlider el: $('.slider')
# @time = null
# $(@slider).bind 'seek', (event, time) => @time = time
# spyOnEvent @slider, 'seek'
# @slider.onSlide {}, value: 20
#
# it 'freeze the slider', ->
# expect(@slider.frozen).toBeTruthy()
#
# it 'update the tooltip', ->
# expect($.fn.qtip).toHaveBeenCalled()
#
# it 'trigger seek event', ->
# expect('seek').toHaveBeenTriggeredOn @slider
# expect(@time).toEqual 20
#
# describe 'onChange', ->
# beforeEach ->
# @slider = new VideoProgressSlider el: $('.slider')
# @slider.onChange {}, value: 20
#
# it 'update the tooltip', ->
# expect($.fn.qtip).toHaveBeenCalled()
#
# describe 'onStop', ->
# beforeEach ->
# @slider = new VideoProgressSlider el: $('.slider')
# @time = null
# $(@slider).bind 'seek', (event, time) => @time = time
# spyOnEvent @slider, 'seek'
# spyOn(window, 'setTimeout')
# @slider.onStop {}, value: 20
#
# it 'freeze the slider', ->
# expect(@slider.frozen).toBeTruthy()
#
# it 'trigger seek event', ->
# expect('seek').toHaveBeenTriggeredOn @slider
# expect(@time).toEqual 20
#
# it 'set timeout to unfreeze the slider', ->
# expect(window.setTimeout).toHaveBeenCalledWith jasmine.any(Function), 200
# window.setTimeout.mostRecentCall.args[0]()
# expect(@slider.frozen).toBeFalsy()
#
# describe 'updateTooltip', ->
# beforeEach ->
# @slider = new VideoProgressSlider el: $('.slider')
# @slider.updateTooltip 90
#
# it 'set the tooltip value', ->
# expect($.fn.qtip).toHaveBeenCalledWith 'option', 'content.text', '1:30'
# TODO: figure out why failing
xdescribe 'VideoProgressSlider', ->
beforeEach ->
jasmine.stubVideoPlayer @
describe 'constructor', ->
describe 'on a non-touch based device', ->
beforeEach ->
spyOn($.fn, 'slider').andCallThrough()
spyOn(window, 'onTouchBasedDevice').andReturn false
@slider = new VideoProgressSlider el: $('.slider')
it 'build the slider', ->
expect(@slider.slider).toBe '.slider'
expect($.fn.slider).toHaveBeenCalledWith
range: 'min'
change: @slider.onChange
slide: @slider.onSlide
stop: @slider.onStop
it 'build the seek handle', ->
expect(@slider.handle).toBe '.slider .ui-slider-handle'
expect($.fn.qtip).toHaveBeenCalledWith
content: "0:00"
position:
my: 'bottom center'
at: 'top center'
container: @slider.handle
hide:
delay: 700
style:
classes: 'ui-tooltip-slider'
widget: true
describe 'on a touch-based device', ->
beforeEach ->
spyOn($.fn, 'slider').andCallThrough()
spyOn(window, 'onTouchBasedDevice').andReturn true
@slider = new VideoProgressSlider el: $('.slider')
it 'does not build the slider', ->
expect(@slider.slider).toBeUndefined
expect($.fn.slider).not.toHaveBeenCalled()
describe 'play', ->
beforeEach ->
@slider = new VideoProgressSlider el: $('.slider')
spyOn($.fn, 'slider').andCallThrough()
describe 'when the slider was already built', ->
beforeEach ->
@slider.play()
it 'does not build the slider', ->
expect($.fn.slider).not.toHaveBeenCalled
describe 'when the slider was not already built', ->
beforeEach ->
@slider.slider = null
@slider.play()
it 'build the slider', ->
expect(@slider.slider).toBe '.slider'
expect($.fn.slider).toHaveBeenCalledWith
range: 'min'
change: @slider.onChange
slide: @slider.onSlide
stop: @slider.onStop
it 'build the seek handle', ->
expect(@slider.handle).toBe '.ui-slider-handle'
expect($.fn.qtip).toHaveBeenCalledWith
content: "0:00"
position:
my: 'bottom center'
at: 'top center'
container: @slider.handle
hide:
delay: 700
style:
classes: 'ui-tooltip-slider'
widget: true
describe 'updatePlayTime', ->
beforeEach ->
@slider = new VideoProgressSlider el: $('.slider')
spyOn($.fn, 'slider').andCallThrough()
describe 'when frozen', ->
beforeEach ->
@slider.frozen = true
@slider.updatePlayTime 20, 120
it 'does not update the slider', ->
expect($.fn.slider).not.toHaveBeenCalled()
describe 'when not frozen', ->
beforeEach ->
@slider.frozen = false
@slider.updatePlayTime 20, 120
it 'update the max value of the slider', ->
expect($.fn.slider).toHaveBeenCalledWith 'option', 'max', 120
it 'update current value of the slider', ->
expect($.fn.slider).toHaveBeenCalledWith 'value', 20
describe 'onSlide', ->
beforeEach ->
@slider = new VideoProgressSlider el: $('.slider')
@time = null
$(@slider).bind 'seek', (event, time) => @time = time
spyOnEvent @slider, 'seek'
@slider.onSlide {}, value: 20
it 'freeze the slider', ->
expect(@slider.frozen).toBeTruthy()
it 'update the tooltip', ->
expect($.fn.qtip).toHaveBeenCalled()
it 'trigger seek event', ->
expect('seek').toHaveBeenTriggeredOn @slider
expect(@time).toEqual 20
describe 'onChange', ->
beforeEach ->
@slider = new VideoProgressSlider el: $('.slider')
@slider.onChange {}, value: 20
it 'update the tooltip', ->
expect($.fn.qtip).toHaveBeenCalled()
describe 'onStop', ->
beforeEach ->
@slider = new VideoProgressSlider el: $('.slider')
@time = null
$(@slider).bind 'seek', (event, time) => @time = time
spyOnEvent @slider, 'seek'
spyOn(window, 'setTimeout')
@slider.onStop {}, value: 20
it 'freeze the slider', ->
expect(@slider.frozen).toBeTruthy()
it 'trigger seek event', ->
expect('seek').toHaveBeenTriggeredOn @slider
expect(@time).toEqual 20
it 'set timeout to unfreeze the slider', ->
expect(window.setTimeout).toHaveBeenCalledWith jasmine.any(Function), 200
window.setTimeout.mostRecentCall.args[0]()
expect(@slider.frozen).toBeFalsy()
describe 'updateTooltip', ->
beforeEach ->
@slider = new VideoProgressSlider el: $('.slider')
@slider.updateTooltip 90
it 'set the tooltip value', ->
expect($.fn.qtip).toHaveBeenCalledWith 'option', 'content.text', '1:30'
#describe 'VideoSpeedControl', ->
# beforeEach ->
# jasmine.stubVideoPlayer @
# $('.speeds').remove()
#
# describe 'constructor', ->
# describe 'always', ->
# beforeEach ->
# @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
#
# it 'add the video speed control to player', ->
# expect($('.secondary-controls').html()).toContain '''
# <div class="speeds">
# <a href="#">
# <h3>Speed</h3>
# <p class="active">1.0x</p>
# </a>
# <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>
# </div>
# '''
#
# it 'bind to change video speed link', ->
# expect($('.video_speeds a')).toHandleWith 'click', @speedControl.changeVideoSpeed
#
# describe 'when running on touch based device', ->
# beforeEach ->
# spyOn(window, 'onTouchBasedDevice').andReturn true
# $('.speeds').removeClass 'open'
# @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
#
# it 'open the speed toggle on click', ->
# $('.speeds').click()
# expect($('.speeds')).toHaveClass 'open'
# $('.speeds').click()
# expect($('.speeds')).not.toHaveClass 'open'
#
# describe 'when running on non-touch based device', ->
# beforeEach ->
# spyOn(window, 'onTouchBasedDevice').andReturn false
# $('.speeds').removeClass 'open'
# @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
#
# it 'open the speed toggle on hover', ->
# $('.speeds').mouseenter()
# expect($('.speeds')).toHaveClass 'open'
# $('.speeds').mouseleave()
# expect($('.speeds')).not.toHaveClass 'open'
#
# it 'close the speed toggle on mouse out', ->
# $('.speeds').mouseenter().mouseleave()
# expect($('.speeds')).not.toHaveClass 'open'
#
# it 'close the speed toggle on click', ->
# $('.speeds').mouseenter().click()
# expect($('.speeds')).not.toHaveClass 'open'
#
# describe 'changeVideoSpeed', ->
# beforeEach ->
# @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
# @video.setSpeed '1.0'
#
# describe 'when new speed is the same', ->
# beforeEach ->
# spyOnEvent @speedControl, 'speedChange'
# $('li[data-speed="1.0"] a').click()
#
# it 'does not trigger speedChange event', ->
# expect('speedChange').not.toHaveBeenTriggeredOn @speedControl
#
# describe 'when new speed is not the same', ->
# beforeEach ->
# @newSpeed = null
# $(@speedControl).bind 'speedChange', (event, newSpeed) => @newSpeed = newSpeed
# spyOnEvent @speedControl, 'speedChange'
# $('li[data-speed="0.75"] a').click()
#
# it 'trigger speedChange event', ->
# expect('speedChange').toHaveBeenTriggeredOn @speedControl
# expect(@newSpeed).toEqual 0.75
#
# describe 'onSpeedChange', ->
# beforeEach ->
# @speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
# $('li[data-speed="1.0"] a').addClass 'active'
# @speedControl.setSpeed '0.75'
#
# it 'set the new speed as active', ->
# expect($('.video_speeds li[data-speed="1.0"]')).not.toHaveClass 'active'
# expect($('.video_speeds li[data-speed="0.75"]')).toHaveClass 'active'
# expect($('.speeds p.active')).toHaveHtml '0.75x'
# TODO: figure out why failing
xdescribe 'VideoSpeedControl', ->
beforeEach ->
jasmine.stubVideoPlayer @
$('.speeds').remove()
describe 'constructor', ->
describe 'always', ->
beforeEach ->
@speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
it 'add the video speed control to player', ->
expect($('.secondary-controls').html()).toContain '''
<div class="speeds">
<a href="#">
<h3>Speed</h3>
<p class="active">1.0x</p>
</a>
<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>
</div>
'''
it 'bind to change video speed link', ->
expect($('.video_speeds a')).toHandleWith 'click', @speedControl.changeVideoSpeed
describe 'when running on touch based device', ->
beforeEach ->
spyOn(window, 'onTouchBasedDevice').andReturn true
$('.speeds').removeClass 'open'
@speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
it 'open the speed toggle on click', ->
$('.speeds').click()
expect($('.speeds')).toHaveClass 'open'
$('.speeds').click()
expect($('.speeds')).not.toHaveClass 'open'
describe 'when running on non-touch based device', ->
beforeEach ->
spyOn(window, 'onTouchBasedDevice').andReturn false
$('.speeds').removeClass 'open'
@speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
it 'open the speed toggle on hover', ->
$('.speeds').mouseenter()
expect($('.speeds')).toHaveClass 'open'
$('.speeds').mouseleave()
expect($('.speeds')).not.toHaveClass 'open'
it 'close the speed toggle on mouse out', ->
$('.speeds').mouseenter().mouseleave()
expect($('.speeds')).not.toHaveClass 'open'
it 'close the speed toggle on click', ->
$('.speeds').mouseenter().click()
expect($('.speeds')).not.toHaveClass 'open'
describe 'changeVideoSpeed', ->
beforeEach ->
@speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
@video.setSpeed '1.0'
describe 'when new speed is the same', ->
beforeEach ->
spyOnEvent @speedControl, 'speedChange'
$('li[data-speed="1.0"] a').click()
it 'does not trigger speedChange event', ->
expect('speedChange').not.toHaveBeenTriggeredOn @speedControl
describe 'when new speed is not the same', ->
beforeEach ->
@newSpeed = null
$(@speedControl).bind 'speedChange', (event, newSpeed) => @newSpeed = newSpeed
spyOnEvent @speedControl, 'speedChange'
$('li[data-speed="0.75"] a').click()
it 'trigger speedChange event', ->
expect('speedChange').toHaveBeenTriggeredOn @speedControl
expect(@newSpeed).toEqual 0.75
describe 'onSpeedChange', ->
beforeEach ->
@speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
$('li[data-speed="1.0"] a').addClass 'active'
@speedControl.setSpeed '0.75'
it 'set the new speed as active', ->
expect($('.video_speeds li[data-speed="1.0"]')).not.toHaveClass 'active'
expect($('.video_speeds li[data-speed="0.75"]')).toHaveClass 'active'
expect($('.speeds p.active')).toHaveHtml '0.75x'
#describe 'VideoVolumeControl', ->
# beforeEach ->
# jasmine.stubVideoPlayer @
# $('.volume').remove()
#
# describe 'constructor', ->
# beforeEach ->
# spyOn($.fn, 'slider')
# @volumeControl = new VideoVolumeControl el: $('.secondary-controls')
#
# it 'initialize currentVolume to 100', ->
# expect(@volumeControl.currentVolume).toEqual 100
#
# it 'render the volume control', ->
# expect($('.secondary-controls').html()).toContain """
# <div class="volume">
# <a href="#"></a>
# <div class="volume-slider-container">
# <div class="volume-slider"></div>
# </div>
# </div>
# """
#
# it 'create the slider', ->
# expect($.fn.slider).toHaveBeenCalledWith
# orientation: "vertical"
# range: "min"
# min: 0
# max: 100
# value: 100
# change: @volumeControl.onChange
# slide: @volumeControl.onChange
#
# it 'bind the volume control', ->
# expect($('.volume>a')).toHandleWith 'click', @volumeControl.toggleMute
#
# expect($('.volume')).not.toHaveClass 'open'
# $('.volume').mouseenter()
# expect($('.volume')).toHaveClass 'open'
# $('.volume').mouseleave()
# expect($('.volume')).not.toHaveClass 'open'
#
# describe 'onChange', ->
# beforeEach ->
# spyOnEvent @volumeControl, 'volumeChange'
# @newVolume = undefined
# @volumeControl = new VideoVolumeControl el: $('.secondary-controls')
# $(@volumeControl).bind 'volumeChange', (event, volume) => @newVolume = volume
#
# describe 'when the new volume is more than 0', ->
# beforeEach ->
# @volumeControl.onChange undefined, value: 60
#
# it 'set the player volume', ->
# expect(@newVolume).toEqual 60
#
# it 'remote muted class', ->
# expect($('.volume')).not.toHaveClass 'muted'
#
# describe 'when the new volume is 0', ->
# beforeEach ->
# @volumeControl.onChange undefined, value: 0
#
# it 'set the player volume', ->
# expect(@newVolume).toEqual 0
#
# it 'add muted class', ->
# expect($('.volume')).toHaveClass 'muted'
#
# describe 'toggleMute', ->
# beforeEach ->
# @newVolume = undefined
# @volumeControl = new VideoVolumeControl el: $('.secondary-controls')
# $(@volumeControl).bind 'volumeChange', (event, volume) => @newVolume = volume
#
# describe 'when the current volume is more than 0', ->
# beforeEach ->
# @volumeControl.currentVolume = 60
# @volumeControl.toggleMute()
#
# it 'save the previous volume', ->
# expect(@volumeControl.previousVolume).toEqual 60
#
# it 'set the player volume', ->
# expect(@newVolume).toEqual 0
#
# describe 'when the current volume is 0', ->
# beforeEach ->
# @volumeControl.currentVolume = 0
# @volumeControl.previousVolume = 60
# @volumeControl.toggleMute()
#
# it 'set the player volume to previous volume', ->
# expect(@newVolume).toEqual 60
# TODO: figure out why failing
xdescribe 'VideoVolumeControl', ->
beforeEach ->
jasmine.stubVideoPlayer @
$('.volume').remove()
describe 'constructor', ->
beforeEach ->
spyOn($.fn, 'slider')
@volumeControl = new VideoVolumeControl el: $('.secondary-controls')
it 'initialize currentVolume to 100', ->
expect(@volumeControl.currentVolume).toEqual 100
it 'render the volume control', ->
expect($('.secondary-controls').html()).toContain """
<div class="volume">
<a href="#"></a>
<div class="volume-slider-container">
<div class="volume-slider"></div>
</div>
</div>
"""
it 'create the slider', ->
expect($.fn.slider).toHaveBeenCalledWith
orientation: "vertical"
range: "min"
min: 0
max: 100
value: 100
change: @volumeControl.onChange
slide: @volumeControl.onChange
it 'bind the volume control', ->
expect($('.volume>a')).toHandleWith 'click', @volumeControl.toggleMute
expect($('.volume')).not.toHaveClass 'open'
$('.volume').mouseenter()
expect($('.volume')).toHaveClass 'open'
$('.volume').mouseleave()
expect($('.volume')).not.toHaveClass 'open'
describe 'onChange', ->
beforeEach ->
spyOnEvent @volumeControl, 'volumeChange'
@newVolume = undefined
@volumeControl = new VideoVolumeControl el: $('.secondary-controls')
$(@volumeControl).bind 'volumeChange', (event, volume) => @newVolume = volume
describe 'when the new volume is more than 0', ->
beforeEach ->
@volumeControl.onChange undefined, value: 60
it 'set the player volume', ->
expect(@newVolume).toEqual 60
it 'remote muted class', ->
expect($('.volume')).not.toHaveClass 'muted'
describe 'when the new volume is 0', ->
beforeEach ->
@volumeControl.onChange undefined, value: 0
it 'set the player volume', ->
expect(@newVolume).toEqual 0
it 'add muted class', ->
expect($('.volume')).toHaveClass 'muted'
describe 'toggleMute', ->
beforeEach ->
@newVolume = undefined
@volumeControl = new VideoVolumeControl el: $('.secondary-controls')
$(@volumeControl).bind 'volumeChange', (event, volume) => @newVolume = volume
describe 'when the current volume is more than 0', ->
beforeEach ->
@volumeControl.currentVolume = 60
@volumeControl.toggleMute()
it 'save the previous volume', ->
expect(@volumeControl.previousVolume).toEqual 60
it 'set the player volume', ->
expect(@newVolume).toEqual 0
describe 'when the current volume is 0', ->
beforeEach ->
@volumeControl.currentVolume = 0
@volumeControl.previousVolume = 60
@volumeControl.toggleMute()
it 'set the player volume to previous volume', ->
expect(@newVolume).toEqual 60
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