Commit 4c4476a7 by Brian Jacobel

Fix lint issues on feature branch

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