Fix issues detected by 'JSHint' and 'JSCS'
Change-Id: Id16d7abe53d5f65c97bf778dc532e404b41283d8
This commit is contained in:
@@ -105,7 +105,6 @@
|
||||
},
|
||||
|
||||
additions: function() {
|
||||
var result = [];
|
||||
return this.accounts.filter(function(account) {
|
||||
return account._pendingAdd;
|
||||
}).map(function(account) {
|
||||
@@ -115,7 +114,6 @@
|
||||
return {account: account};
|
||||
}
|
||||
});
|
||||
return result;
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
@@ -484,7 +484,7 @@
|
||||
switch (action.__key) {
|
||||
case ChangeActions.REVERT:
|
||||
this._setLabelValuesOnRevert(obj.change_id);
|
||||
// Fall through.
|
||||
/* falls through */
|
||||
case RevisionActions.CHERRYPICK:
|
||||
page.show(this.changePath(obj._number));
|
||||
break;
|
||||
|
@@ -334,15 +334,6 @@ limitations under the License.
|
||||
test('branch name cleared when re-open cherrypick', function() {
|
||||
var cherryPickButton =
|
||||
element.$$('gr-button[data-action-key="cherrypick"]');
|
||||
var action = {
|
||||
__key: 'cherrypick',
|
||||
__type: 'revision',
|
||||
__primary: false,
|
||||
enabled: true,
|
||||
label: 'Cherry Pick',
|
||||
method: 'POST',
|
||||
title: 'Cherry pick change to a different branch',
|
||||
};
|
||||
var emptyBranchName = '';
|
||||
element.$.confirmCherrypick.branch = 'master';
|
||||
|
||||
|
@@ -515,14 +515,14 @@ limitations under the License.
|
||||
patchNum: 2,
|
||||
};
|
||||
element._change = {
|
||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
||||
revisions: {
|
||||
rev1: {_number: 1},
|
||||
},
|
||||
current_revision: 'rev1',
|
||||
status: element.ChangeStatus.MERGED,
|
||||
labels: {},
|
||||
actions: {},
|
||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
||||
revisions: {
|
||||
rev1: {_number: 1},
|
||||
},
|
||||
current_revision: 'rev1',
|
||||
status: element.ChangeStatus.MERGED,
|
||||
labels: {},
|
||||
actions: {},
|
||||
};
|
||||
|
||||
var urlParamStub = sandbox.stub(element, '_getUrlParameter',
|
||||
@@ -540,6 +540,7 @@ limitations under the License.
|
||||
suite('scroll related tests', function() {
|
||||
test('document scrolling calls function to set scroll height',
|
||||
function(done) {
|
||||
var originalHeight = document.body.scrollHeight;
|
||||
var scrollStub = sandbox.stub(element, '_handleScroll',
|
||||
function() {
|
||||
assert.isTrue(scrollStub.called);
|
||||
@@ -547,7 +548,6 @@ limitations under the License.
|
||||
originalHeight + 'px';
|
||||
done();
|
||||
});
|
||||
var originalHeight = document.body.scrollHeight;
|
||||
document.body.style.height = '10000px';
|
||||
document.body.scrollTop = TEST_SCROLL_TOP_PX;
|
||||
element._handleScroll();
|
||||
|
@@ -150,9 +150,11 @@ limitations under the License.
|
||||
var toggleLeftDiffStub = sandbox.stub();
|
||||
// Property getter cannot be stubbed w/ sandbox due to a bug in Sinon.
|
||||
// https://github.com/sinonjs/sinon/issues/781
|
||||
var diffsStub = sinon.stub(element, 'diffs', {get: function() {
|
||||
return [{toggleLeftDiff: toggleLeftDiffStub}];
|
||||
}});
|
||||
var diffsStub = sinon.stub(element, 'diffs', {
|
||||
get: function() {
|
||||
return [{toggleLeftDiff: toggleLeftDiffStub}];
|
||||
},
|
||||
});
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 65, 'shift'); // 'A'
|
||||
assert.isTrue(toggleLeftDiffStub.calledOnce);
|
||||
diffsStub.restore();
|
||||
@@ -401,7 +403,6 @@ limitations under the License.
|
||||
};
|
||||
element.selectedIndex = 0;
|
||||
flushAsynchronousOperations();
|
||||
var select = element.$.modeSelect;
|
||||
var diffDisplay = element.diffs[0];
|
||||
element._userPrefs = {diff_view: 'SIDE_BY_SIDE'};
|
||||
assert.equal(element._getDiffViewMode(), 'SIDE_BY_SIDE');
|
||||
|
@@ -116,11 +116,6 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('messages', function() {
|
||||
var dates = [
|
||||
'2016-01-12 20:28:33.038000',
|
||||
'2016-01-12 21:28:33.038000',
|
||||
'2016-01-12 22:28:33.038000'
|
||||
];
|
||||
var author = {
|
||||
_account_id: 42,
|
||||
name: 'Marvin the Paranoid Android',
|
||||
|
@@ -74,7 +74,7 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('time and timeEnd', function() {
|
||||
var nowStub = sinon.stub(element, 'now').returns(0);
|
||||
var nowStub = sandbox.stub(element, 'now').returns(0);
|
||||
element.time('foo');
|
||||
nowStub.returns(1);
|
||||
element.time('bar');
|
||||
@@ -99,7 +99,7 @@ limitations under the License.
|
||||
|
||||
test('pluginsLoaded reports time', function() {
|
||||
Gerrit._arePluginsLoaded.returns(true);
|
||||
var nowStub = sinon.stub(element, 'now').returns(42);
|
||||
sandbox.stub(element, 'now').returns(42);
|
||||
element.pluginsLoaded();
|
||||
assert.isTrue(element.defaultReporter.calledWithExactly(
|
||||
'timing-report', 'UI Latency', 'PluginsLoaded', 42
|
||||
|
@@ -164,7 +164,7 @@
|
||||
return accounts.map(function(acct) {
|
||||
return predicate + ':"' + acct.name + ' <' + acct.email + '>"';
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -69,7 +69,6 @@
|
||||
GrDiffBuilderSideBySide.prototype._getNextContentOnSide = function(
|
||||
content, side) {
|
||||
var tr = content.parentElement.parentElement;
|
||||
var content;
|
||||
while (tr = tr.nextSibling) {
|
||||
content = tr.querySelector(
|
||||
'td.content .contentText[data-side="' + side + '"]');
|
||||
|
@@ -62,7 +62,6 @@
|
||||
GrDiffBuilderUnified.prototype._getNextContentOnSide = function(
|
||||
content, side) {
|
||||
var tr = content.parentElement.parentElement;
|
||||
var content;
|
||||
while (tr = tr.nextSibling) {
|
||||
if (tr.classList.contains('both') || (
|
||||
(side === 'left' && tr.classList.contains('remove')) ||
|
||||
|
@@ -234,10 +234,6 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('collapsible drafts', function() {
|
||||
element.addEventListener('reply', function(e) {
|
||||
assert.ok(e.detail.comment);
|
||||
done();
|
||||
});
|
||||
assert.isTrue(element.collapsed);
|
||||
assert.isFalse(isVisible(element.$$('gr-linked-text')),
|
||||
'gr-linked-text is not visible');
|
||||
|
@@ -489,6 +489,7 @@ limitations under the License.
|
||||
resolvePrefs({diff_view: 'UNIFIED'});
|
||||
flushAsynchronousOperations();
|
||||
assert.equal(select.value, 'SIDE_BY_SIDE');
|
||||
getPreferencesStub.restore();
|
||||
});
|
||||
|
||||
test('unified view is always default on small screens', function() {
|
||||
@@ -522,6 +523,7 @@ limitations under the License.
|
||||
|
||||
// On small screens, unified should override user perferences
|
||||
assert.equal(select.value, 'UNIFIED_DIFF');
|
||||
getPreferencesStub.restore();
|
||||
});
|
||||
|
||||
test('_loadHash', function() {
|
||||
|
@@ -396,12 +396,12 @@
|
||||
this.patchRange.patchNum,
|
||||
this.path,
|
||||
this._handleGetDiffError.bind(this)).then(function(diff) {
|
||||
this.filesWeblinks = {
|
||||
meta_a: diff && diff.meta_a && diff.meta_a.web_links,
|
||||
meta_b: diff && diff.meta_b && diff.meta_b.web_links,
|
||||
};
|
||||
return diff;
|
||||
}.bind(this));
|
||||
this.filesWeblinks = {
|
||||
meta_a: diff && diff.meta_a && diff.meta_a.web_links,
|
||||
meta_b: diff && diff.meta_b && diff.meta_b.web_links,
|
||||
};
|
||||
return diff;
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_getDiffComments: function() {
|
||||
|
@@ -493,6 +493,7 @@ limitations under the License.
|
||||
});
|
||||
var spy = sinon.spy(element, '_handleShowDiff');
|
||||
element.set('expanded', true);
|
||||
assert.isTrue(spy.called);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -173,9 +173,6 @@ limitations under the License.
|
||||
line.beforeNumber = 36;
|
||||
el.setAttribute('data-side', 'right');
|
||||
|
||||
var expectedStart = 6;
|
||||
var expectedLength = line.text.length - expectedStart;
|
||||
|
||||
element.annotate(el, line);
|
||||
|
||||
assert.isFalse(annotateElementStub.called);
|
||||
|
@@ -47,7 +47,6 @@
|
||||
'text/x-yaml': 'yaml',
|
||||
};
|
||||
var ASYNC_DELAY = 10;
|
||||
var HLJS_PATH = 'bower_components/highlightjs/highlight.min.js';
|
||||
|
||||
var CLASS_WHITELIST = {
|
||||
'gr-diff gr-syntax gr-syntax-literal': true,
|
||||
@@ -278,8 +277,8 @@
|
||||
* @param {!Object} state The processing state for the layer.
|
||||
*/
|
||||
_processNextLine: function(state) {
|
||||
var baseLine = undefined;
|
||||
var revisionLine = undefined;
|
||||
var baseLine;
|
||||
var revisionLine;
|
||||
|
||||
var section = this.diff.content[state.sectionIndex];
|
||||
if (section.ab) {
|
||||
|
@@ -311,7 +311,7 @@ limitations under the License.
|
||||
text: function() { return Promise.resolve(')]}\'{}'); }
|
||||
},
|
||||
];
|
||||
var fetchStub = sandbox.stub(window, 'fetch', function(url) {
|
||||
sandbox.stub(window, 'fetch', function(url) {
|
||||
if (url === '/accounts/self/detail') {
|
||||
return Promise.resolve(responses.shift());
|
||||
}
|
||||
|
Reference in New Issue
Block a user