Commit 4c4476a7 by Brian Jacobel

Fix lint issues on feature branch

parent a60d456f
/* globals /* globals
Discussion, DiscussionCourseSettings, DiscussionViewSpecHelper, DiscussionSpecHelper, _, Discussion, DiscussionCourseSettings, DiscussionViewSpecHelper, DiscussionSpecHelper,
DiscussionThreadListView, DiscussionUtil, Thread DiscussionThreadListView, DiscussionUtil, Thread
*/ */
(function() { (function() {
...@@ -156,22 +156,22 @@ ...@@ -156,22 +156,22 @@
return expect(this.view.$('.forum-nav-filter-main-control').val()).toEqual('all'); return expect(this.view.$('.forum-nav-filter-main-control').val()).toEqual('all');
}); });
checkThreadsOrdering = function(view, sort_order, type) { checkThreadsOrdering = function(view, sortOrder, type) {
expect(view.$el.find('.forum-nav-thread').children().length).toEqual(4); expect(view.$el.find('.forum-nav-thread').children().length).toEqual(4);
expect(view.$el.find('.forum-nav-thread:nth-child(1) .forum-nav-thread-title').text()) expect(view.$el.find('.forum-nav-thread:nth-child(1) .forum-nav-thread-title').text())
.toEqual(sort_order[0]); .toEqual(sortOrder[0]);
expect(view.$el.find('.forum-nav-thread:nth-child(2) .forum-nav-thread-title').text()) expect(view.$el.find('.forum-nav-thread:nth-child(2) .forum-nav-thread-title').text())
.toEqual(sort_order[1]); .toEqual(sortOrder[1]);
expect(view.$el.find('.forum-nav-thread:nth-child(3) .forum-nav-thread-title').text()) expect(view.$el.find('.forum-nav-thread:nth-child(3) .forum-nav-thread-title').text())
.toEqual(sort_order[2]); .toEqual(sortOrder[2]);
expect(view.$el.find('.forum-nav-thread:nth-child(4) .forum-nav-thread-title').text()) expect(view.$el.find('.forum-nav-thread:nth-child(4) .forum-nav-thread-title').text())
.toEqual(sort_order[3]); .toEqual(sortOrder[3]);
return expect(view.$el.find('.forum-nav-sort-control').val()).toEqual(type); return expect(view.$el.find('.forum-nav-sort-control').val()).toEqual(type);
}; };
describe('thread rendering should be correct', function() { describe('thread rendering should be correct', function() {
var checkRender; var checkRender;
checkRender = function(threads, type, sort_order) { checkRender = function(threads, type, sortOrder) {
var discussion, view; var discussion, view;
discussion = new Discussion(_.map(threads, function(thread) { discussion = new Discussion(_.map(threads, function(thread) {
return new Thread(thread); return new Thread(thread);
...@@ -181,56 +181,56 @@ ...@@ -181,56 +181,56 @@
}); });
view = makeView(discussion); view = makeView(discussion);
view.render(); view.render();
checkThreadsOrdering(view, sort_order, type); checkThreadsOrdering(view, sortOrder, type);
expect(view.$el.find('.forum-nav-thread-comments-count:visible').length) expect(view.$el.find('.forum-nav-thread-comments-count:visible').length)
.toEqual(type === 'votes' ? 0 : 4); .toEqual(type === 'votes' ? 0 : 4);
expect(view.$el.find('.forum-nav-thread-votes-count:visible').length) expect(view.$el.find('.forum-nav-thread-votes-count:visible').length)
.toEqual(type === 'votes' ? 4 : 0); .toEqual(type === 'votes' ? 4 : 0);
if (type === 'votes') { if (type === 'votes') {
return expect(_.map(view.$el.find('.forum-nav-thread-votes-count'), function(element) { expect(_.map(view.$el.find('.forum-nav-thread-votes-count'), function(element) {
return $(element).text().trim(); return $(element).text().trim();
})).toEqual(['+25 votes', '+20 votes', '+42 votes', '+12 votes']); })).toEqual(['+25 votes', '+20 votes', '+42 votes', '+12 votes']);
} }
}; };
it('with sort preference activity', function() { it('with sort preference activity', function() {
return checkRender(this.threads, 'activity', ['Thread1', 'Thread2', 'Thread3', 'Thread4']); checkRender(this.threads, 'activity', ['Thread1', 'Thread2', 'Thread3', 'Thread4']);
}); });
it('with sort preference votes', function() { it('with sort preference votes', function() {
return checkRender(this.threads, 'votes', ['Thread4', 'Thread1', 'Thread2', 'Thread3']); checkRender(this.threads, 'votes', ['Thread4', 'Thread1', 'Thread2', 'Thread3']);
}); });
it('with sort preference comments', function() { it('with sort preference comments', function() {
return checkRender(this.threads, 'comments', ['Thread1', 'Thread4', 'Thread3', 'Thread2']); checkRender(this.threads, 'comments', ['Thread1', 'Thread4', 'Thread3', 'Thread2']);
}); });
}); });
describe('Sort change should be correct', function() { describe('Sort change should be correct', function() {
var changeSorting; var changeSorting;
changeSorting = function(threads, selected_type, new_type, sort_order) { changeSorting = function(threads, selectedType, newType, sortOrder) {
var discussion, sortControl, sorted_threads, view; var discussion, sortControl, sortedThreads, view;
discussion = new Discussion(_.map(threads, function(thread) { discussion = new Discussion(_.map(threads, function(thread) {
return new Thread(thread); return new Thread(thread);
}), { }), {
pages: 1, pages: 1,
sort: selected_type sort: selectedType
}); });
view = makeView(discussion); view = makeView(discussion);
view.render(); view.render();
sortControl = view.$el.find('.forum-nav-sort-control'); sortControl = view.$el.find('.forum-nav-sort-control');
expect(sortControl.val()).toEqual(selected_type); expect(sortControl.val()).toEqual(selectedType);
sorted_threads = []; sortedThreads = [];
if (new_type === 'activity') { if (newType === 'activity') {
sorted_threads = [threads[0], threads[3], threads[1], threads[2]]; sortedThreads = [threads[0], threads[3], threads[1], threads[2]];
} else if (new_type === 'comments') { } else if (newType === 'comments') {
sorted_threads = [threads[0], threads[3], threads[2], threads[1]]; sortedThreads = [threads[0], threads[3], threads[2], threads[1]];
} else if (new_type === 'votes') { } else if (newType === 'votes') {
sorted_threads = [threads[3], threads[0], threads[1], threads[2]]; sortedThreads = [threads[3], threads[0], threads[1], threads[2]];
} }
$.ajax.and.callFake(function(params) { $.ajax.and.callFake(function(params) {
params.success({ params.success({
'discussion_data': sorted_threads, discussion_data: sortedThreads,
page: 1, page: 1,
num_pages: 1 num_pages: 1
}); });
...@@ -239,9 +239,9 @@ ...@@ -239,9 +239,9 @@
} }
}; };
}); });
sortControl.val(new_type).change(); sortControl.val(newType).change();
expect($.ajax).toHaveBeenCalled(); expect($.ajax).toHaveBeenCalled();
checkThreadsOrdering(view, sort_order, new_type); checkThreadsOrdering(view, sortOrder, newType);
}; };
it('with sort preference activity', function() { it('with sort preference activity', function() {
...@@ -290,7 +290,7 @@ ...@@ -290,7 +290,7 @@
}); });
it('renders search alert with custom class', function() { it('renders search alert with custom class', function() {
var foo, messages; var messages;
testAlertMessages([]); testAlertMessages([]);
this.view.addSearchAlert('foo', 'custom-class'); this.view.addSearchAlert('foo', 'custom-class');
...@@ -299,7 +299,7 @@ ...@@ -299,7 +299,7 @@
expect(messages[0].text).toEqual('foo'); expect(messages[0].text).toEqual('foo');
expect(messages[0].css_class).toEqual('search-alert custom-class'); expect(messages[0].css_class).toEqual('search-alert custom-class');
foo = this.view.addSearchAlert('bar', 'other-class'); this.view.addSearchAlert('bar', 'other-class');
messages = getAlertMessagesAndClasses(); messages = getAlertMessagesAndClasses();
expect(messages.length).toEqual(2); expect(messages.length).toEqual(2);
...@@ -572,11 +572,7 @@ ...@@ -572,11 +572,7 @@
}); });
describe('when shown', function() { describe('when shown', function() {
beforeEach(function() { it('should show again when header button is clicked', function() {
return $('.forum-nav-browse').click();
});
it('should hide when header button is clicked', function() {
$('.forum-nav-browse').click(); $('.forum-nav-browse').click();
return expectBrowseMenuVisible(false); return expectBrowseMenuVisible(false);
}); });
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
BreadcrumbsModel = Backbone.Model.extend({ BreadcrumbsModel = Backbone.Model.extend({
defaults: { defaults: {
contents: [], contents: []
} }
}); });
......
...@@ -11,14 +11,13 @@ ...@@ -11,14 +11,13 @@
numPages = options.numPages; numPages = options.numPages;
// Roles are not included in user profile page, but they are not used for anything // Roles are not included in user profile page, but they are not used for anything
window.DiscussionUtil.loadRoles({ window.DiscussionUtil.loadRoles({
'Moderator': [], Moderator: [],
'Administrator': [], Administrator: [],
'Community TA': [] 'Community TA': []
}); });
window.$$course_id = options.courseId; window.$$course_id = options.courseId;
window.user = new window.DiscussionUser(userInfo); window.user = new window.DiscussionUser(userInfo);
// jshint nonew:false new DiscussionUserProfileView({ // eslint-disable-line no-new
new DiscussionUserProfileView({
el: $element, el: $element,
collection: threads, collection: threads,
page: page, page: page,
......
...@@ -62,15 +62,7 @@ define( ...@@ -62,15 +62,7 @@ define(
}); });
describe('pagination rendering should be correct', function() { describe('pagination rendering should be correct', function() {
var baseUri, checkRender, pageInfo; var checkRender = function(params) {
baseUri = URI(window.location);
pageInfo = function(page) {
return {
url: baseUri.clone().addSearch('page', page).toString(),
number: page
};
};
checkRender = function(params) {
var getPageNumber, paginator, view; var getPageNumber, paginator, view;
view = makeView([], params.page, params.numPages); view = makeView([], params.page, params.numPages);
paginator = view.$('.discussion-paginator'); paginator = view.$('.discussion-paginator');
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
define([ define([
'backbone', 'backbone',
'edx-ui-toolkit/js/utils/html-utils', 'edx-ui-toolkit/js/utils/html-utils',
'text!discussion/templates/fake-breadcrumbs.underscore', 'text!discussion/templates/fake-breadcrumbs.underscore'
], ],
function(Backbone, HtmlUtils, breadcrumbsTemplate) { function(Backbone, HtmlUtils, breadcrumbsTemplate) {
var DiscussionFakeBreadcrumbs = Backbone.View.extend({ var DiscussionFakeBreadcrumbs = Backbone.View.extend({
......
...@@ -12,7 +12,7 @@ define(['jquery', 'logger', 'js/courseware/courseware_factory'], function($, Log ...@@ -12,7 +12,7 @@ define(['jquery', 'logger', 'js/courseware/courseware_factory'], function($, Log
$('.external-link').click(); $('.external-link').click();
expect(Logger.log).toHaveBeenCalledWith('edx.ui.lms.link_clicked', { expect(Logger.log).toHaveBeenCalledWith('edx.ui.lms.link_clicked', {
target_url: 'http://example.com/', target_url: 'http://example.com/',
current_url: 'http://' + window.location.host + '/context.html' current_url: window.location.toString()
}); });
}); });
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
paths: { paths: {
'gettext': 'xmodule_js/common_static/js/test/i18n', 'gettext': 'xmodule_js/common_static/js/test/i18n',
'codemirror': 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror', 'codemirror': 'xmodule_js/common_static/js/vendor/CodeMirror/codemirror',
'jquery': 'common/js/vendor/jquery', jquery: 'common/js/vendor/jquery',
'jquery-migrate': 'common/js/vendor/jquery-migrate', 'jquery-migrate': 'common/js/vendor/jquery-migrate',
'jquery.ui': 'xmodule_js/common_static/js/vendor/jquery-ui.min', 'jquery.ui': 'xmodule_js/common_static/js/vendor/jquery-ui.min',
'jquery.eventDrag': 'xmodule_js/common_static/js/vendor/jquery.event.drag-2.2', 'jquery.eventDrag': 'xmodule_js/common_static/js/vendor/jquery.event.drag-2.2',
......
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