Add jasmine test for notification dismissal on course outline

This commit is contained in:
Ben McMorran
2014-08-14 17:15:27 -04:00
parent 4fcb6c925a
commit 319b53bb3c
2 changed files with 31 additions and 18 deletions

View File

@@ -7,7 +7,8 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
getItemsOfType, getItemHeaders, verifyItemsExpanded, expandItemsAndVerifyState, collapseItemsAndVerifyState,
createMockCourseJSON, createMockSectionJSON, createMockSubsectionJSON, verifyTypePublishable,
mockCourseJSON, mockEmptyCourseJSON, mockSingleSectionCourseJSON, createMockVerticalJSON,
mockOutlinePage = readFixtures('mock/mock-course-outline-page.underscore');
mockOutlinePage = readFixtures('mock/mock-course-outline-page.underscore'),
mockRerunNotification = readFixtures('mock/mock-course-rerun-notification.underscore');
createMockCourseJSON = function(options, children) {
return $.extend(true, {}, {
@@ -243,6 +244,18 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers"
});
});
describe("Rerun notification", function () {
it("can be dismissed", function () {
appendSetFixtures(mockRerunNotification);
createCourseOutlinePage(this, mockEmptyCourseJSON);
expect($('.wrapper-alert-announcement')).not.toHaveClass('is-hidden');
$('.dismiss-button').click();
create_sinon.expectJsonRequest(requests, 'DELETE', 'dummy_dismiss_url');
create_sinon.respondToDelete(requests);
expect($('.wrapper-alert-announcement')).toHaveClass('is-hidden');
});
});
describe("Button bar", function() {
it('can add a section', function() {
createCourseOutlinePage(this, mockEmptyCourseJSON);

View File

@@ -1,9 +1,9 @@
/**
* This page is used to show the user an outline of the course.
*/
define(["domReady", "jquery", "underscore", "gettext", "js/views/pages/base_page", "js/views/utils/xblock_utils",
define(["jquery", "underscore", "gettext", "js/views/pages/base_page", "js/views/utils/xblock_utils",
"js/views/course_outline"],
function (domReady, $, _, gettext, BasePage, XBlockViewUtils, CourseOutlineView) {
function ($, _, gettext, BasePage, XBlockViewUtils, CourseOutlineView) {
var expandedLocators, CourseOutlinePage;
CourseOutlinePage = BasePage.extend({
@@ -25,6 +25,7 @@ define(["domReady", "jquery", "underscore", "gettext", "js/views/pages/base_page
self.outlineView.handleAddEvent(event);
});
this.model.on('change', this.setCollapseExpandVisibility, this);
$('.dismiss-button').bind('click', this.dismissNotification)
},
setCollapseExpandVisibility: function() {
@@ -97,6 +98,20 @@ define(["domReady", "jquery", "underscore", "gettext", "js/views/pages/base_page
}
}, this);
}
},
/**
* Dismiss the course rerun notification.
*/
dismissNotification: function (e) {
e.preventDefault();
$.ajax({
url: $('.dismiss-button').data('dismiss-link'),
type: 'DELETE',
success: function(result) {
$('.wrapper-alert-announcement').removeClass('is-shown').addClass('is-hidden')
}
});
}
});
@@ -149,20 +164,5 @@ define(["domReady", "jquery", "underscore", "gettext", "js/views/pages/base_page
}
};
var dismissNotification = function (e) {
e.preventDefault();
$.ajax({
url: $('.dismiss-button').data('dismiss-link'),
type: 'DELETE',
success: function(result) {
$('.wrapper-alert-announcement').removeClass('is-shown').addClass('is-hidden')
}
});
};
domReady(function () {
$('.dismiss-button').bind('click', dismissNotification);
});
return CourseOutlinePage;
}); // end define();