Commit b6e82afb by Jay Zoldak

Merge pull request #1681 from MITx/fix/will/fix_broken_jasmine_lms_tests

Fix/will/fix broken jasmine lms tests
parents eff6f1d1 9d8c023a
{ {
"js_files": [ "static_files": [
"/static/js/vendor/RequireJS.js", "js/vendor/RequireJS.js",
"/static/js/vendor/jquery.min.js", "js/vendor/jquery.min.js",
"/static/js/vendor/jquery-ui.min.js", "js/vendor/jquery-ui.min.js",
"/static/js/vendor/jquery.ui.draggable.js", "js/vendor/jquery.ui.draggable.js",
"/static/js/vendor/jquery.cookie.js", "js/vendor/jquery.cookie.js",
"/static/js/vendor/json2.js", "js/vendor/json2.js",
"/static/js/vendor/underscore-min.js", "js/vendor/underscore-min.js",
"/static/js/vendor/backbone-min.js" "js/vendor/backbone-min.js"
] ]
} }
...@@ -13,14 +13,19 @@ ...@@ -13,14 +13,19 @@
<script src="{% static 'js/vendor/jasmine-jquery.js' %}"></script> <script src="{% static 'js/vendor/jasmine-jquery.js' %}"></script>
<script src="{% static 'console-runner.js' %}"></script> <script src="{% static 'console-runner.js' %}"></script>
{% load compressed %}
{# static files #}
{% for url in suite.static_files %}
<script src="{{ STATIC_URL }}{{ url }}"></script>
{% endfor %}
{% compressed_js 'js-test-source' %}
{# source files #} {# source files #}
{% for url in suite.js_files %} {% for url in suite.js_files %}
<script src="{{ url }}"></script> <script src="{{ url }}"></script>
{% endfor %} {% endfor %}
{% load compressed %}
{# static files #}
{% compressed_js 'js-test-source' %}
{# spec files #} {# spec files #}
{% compressed_js 'spec' %} {% compressed_js 'spec' %}
......
...@@ -5,8 +5,5 @@ ...@@ -5,8 +5,5 @@
"/static/js/vendor/jquery-ui.min.js", "/static/js/vendor/jquery-ui.min.js",
"/static/js/vendor/jquery.leanModal.min.js", "/static/js/vendor/jquery.leanModal.min.js",
"/static/js/vendor/flot/jquery.flot.js" "/static/js/vendor/flot/jquery.flot.js"
],
"static_files": [
"js/application.js"
] ]
} }
...@@ -4,9 +4,6 @@ describe 'Calculator', -> ...@@ -4,9 +4,6 @@ describe 'Calculator', ->
@calculator = new Calculator @calculator = new Calculator
describe 'bind', -> describe 'bind', ->
beforeEach ->
Calculator.bind()
it 'bind the calculator button', -> it 'bind the calculator button', ->
expect($('.calc')).toHandleWith 'click', @calculator.toggle expect($('.calc')).toHandleWith 'click', @calculator.toggle
...@@ -31,12 +28,19 @@ describe 'Calculator', -> ...@@ -31,12 +28,19 @@ describe 'Calculator', ->
$('form#calculator').submit() $('form#calculator').submit()
describe 'toggle', -> describe 'toggle', ->
it 'toggle the calculator and focus the input', -> it 'focuses the input when toggled', ->
spyOn $.fn, 'focus'
@calculator.toggle(jQuery.Event("click")) # Since the focus is called asynchronously, we need to
# wait until focus() is called.
didFocus = false
runs ->
spyOn($.fn, 'focus').andCallFake (elementName) -> didFocus = true
@calculator.toggle(jQuery.Event("click"))
waitsFor (-> didFocus), "focus() should have been called on the input", 1000
expect($('li.calc-main')).toHaveClass('open') runs ->
expect($('#calculator_wrapper #calculator_input').focus).toHaveBeenCalled() expect($('#calculator_wrapper #calculator_input').focus).toHaveBeenCalled()
it 'toggle the close button on the calculator button', -> it 'toggle the close button on the calculator button', ->
@calculator.toggle(jQuery.Event("click")) @calculator.toggle(jQuery.Event("click"))
......
...@@ -22,18 +22,23 @@ describe 'Tab', -> ...@@ -22,18 +22,23 @@ describe 'Tab', ->
it 'bind the tabs', -> it 'bind the tabs', ->
expect($.fn.tabs).toHaveBeenCalledWith show: @tab.onShow expect($.fn.tabs).toHaveBeenCalledWith show: @tab.onShow
# As of jQuery 1.9, the onShow callback is deprecated
# http://jqueryui.com/upgrade-guide/1.9/#deprecated-show-event-renamed-to-activate
# The code below tests that onShow does what is expected,
# but note that onShow will NOT be called when the user
# clicks on the tab if we're using jQuery version >= 1.9
describe 'onShow', -> describe 'onShow', ->
beforeEach -> beforeEach ->
@tab = new Tab 1, @items @tab = new Tab 1, @items
$('[href="#tab-1-0"]').click() @tab.onShow($('#tab-1-0'), {'index': 1})
it 'replace content in the container', -> it 'replace content in the container', ->
$('[href="#tab-1-1"]').click() @tab.onShow($('#tab-1-1'), {'index': 1})
expect($('#tab-1-0').html()).toEqual '' expect($('#tab-1-0').html()).toEqual ''
expect($('#tab-1-1').html()).toEqual 'Video 2' expect($('#tab-1-1').html()).toEqual 'Video 2'
expect($('#tab-1-2').html()).toEqual '' expect($('#tab-1-2').html()).toEqual ''
it 'trigger contentChanged event on the element', -> it 'trigger contentChanged event on the element', ->
spyOnEvent @tab.el, 'contentChanged' spyOnEvent @tab.el, 'contentChanged'
$('[href="#tab-1-1"]').click() @tab.onShow($('#tab-1-1'), {'index': 1})
expect('contentChanged').toHaveBeenTriggeredOn @tab.el expect('contentChanged').toHaveBeenTriggeredOn @tab.el
...@@ -32,11 +32,9 @@ describe 'Navigation', -> ...@@ -32,11 +32,9 @@ describe 'Navigation', ->
heightStyle: 'content' heightStyle: 'content'
it 'binds the accordionchange event', -> it 'binds the accordionchange event', ->
Navigation.bind()
expect($('#accordion')).toHandleWith 'accordionchange', @navigation.log expect($('#accordion')).toHandleWith 'accordionchange', @navigation.log
it 'bind the navigation toggle', -> it 'bind the navigation toggle', ->
Navigation.bind()
expect($('#open_close_accordion a')).toHandleWith 'click', @navigation.toggle expect($('#open_close_accordion a')).toHandleWith 'click', @navigation.toggle
describe 'when the #accordion does not exists', -> describe 'when the #accordion does not exists', ->
...@@ -45,7 +43,6 @@ describe 'Navigation', -> ...@@ -45,7 +43,6 @@ describe 'Navigation', ->
it 'does not activate the accordion', -> it 'does not activate the accordion', ->
spyOn $.fn, 'accordion' spyOn $.fn, 'accordion'
Navigation.bind()
expect($('#accordion').accordion).wasNotCalled() expect($('#accordion').accordion).wasNotCalled()
describe 'toggle', -> describe 'toggle', ->
......
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