Fix syntax error in selectors .attr() now returns a string (though it can still be passed an integer) Fixes checkbox test failures Remove remaining references to jquery.min (in wrong folder) $.ajax now returns 422 if type is json and body is not JSON, e.g. '' Substitute prop for attr Remove references to jquery.min, add jquery.migrate (again) "Fix" jquery karma config This wasn't suppoed to survive the merge This throws an error when called with an 'undefined' error Fix Karma warning about [re|un]loading the window Fix path for jquery in cms-squire tests Move jasmine.clock.uninstall() to afterEach so it runs even on failure Fix test failing due to timezone issues Do the timeout before the window scrolling (so handler will not be _.throttled) Fix an alert() triggered by window.onBeforeUnload while testing in Chrome
51 lines
2.4 KiB
JavaScript
51 lines
2.4 KiB
JavaScript
define(['jquery', 'logger', 'js/courseware/toggle_element_visibility', 'moment'],
|
|
function ($, Logger, ToggleElementVisibility, moment) {
|
|
'use strict';
|
|
|
|
describe('show/hide with mouse click', function () {
|
|
|
|
beforeEach(function() {
|
|
loadFixtures('js/fixtures/courseware/course_updates.html');
|
|
/*jshint newcap: false */
|
|
ToggleElementVisibility();
|
|
/*jshint newcap: true */
|
|
spyOn(Logger, 'log');
|
|
});
|
|
|
|
it('ensures update will hide on hide button click', function () {
|
|
var $shownUpdate = $('.toggle-visibility-element:not(.hidden)').first(),
|
|
$updateButton = $shownUpdate.siblings('.toggle-visibility-button');
|
|
$updateButton.trigger('click');
|
|
expect($shownUpdate).toHaveClass('hidden');
|
|
expect($updateButton.text()).toEqual('Show');
|
|
});
|
|
|
|
it('ensures update will show on show button click', function () {
|
|
var $hiddenUpdate = $('.toggle-visibility-element.hidden').first(),
|
|
$updateButton = $hiddenUpdate.siblings('.toggle-visibility-button');
|
|
$updateButton.trigger('click');
|
|
expect($hiddenUpdate).not.toHaveClass('hidden');
|
|
expect($updateButton.text()).toEqual('Hide');
|
|
});
|
|
|
|
it('ensures old updates will show on button click', function () {
|
|
// on page load old updates will be hidden
|
|
var $oldUpdates = $('.toggle-visibility-element.old-updates');
|
|
expect($oldUpdates).toHaveClass('hidden');
|
|
|
|
// on click on show earlier update button old updates will be shown
|
|
$('.toggle-visibility-button.show-older-updates').trigger('click');
|
|
expect($oldUpdates).not.toHaveClass('hidden');
|
|
});
|
|
|
|
it('sends a tracking event on hide and show', function () {
|
|
var $update = $('.toggle-visibility-element:not(.hidden)').first();
|
|
$update.siblings('.toggle-visibility-button').trigger('click');
|
|
expect(Logger.log).toHaveBeenCalledWith('edx.course.home.course_update.toggled', {
|
|
action: 'hide',
|
|
publish_date: moment('December 1, 2015', 'MMM DD, YYYY').format()
|
|
});
|
|
});
|
|
});
|
|
});
|