Fix issues detected by 'JSHint' and 'JSCS'
Change-Id: Ibee5d0843da5776ab1ad43158227178105467d2e
This commit is contained in:
@@ -172,7 +172,7 @@
|
|||||||
if (!this._canSubmitChange()) {
|
if (!this._canSubmitChange()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// no break here, fallthrough.
|
/* falls through */ // required by JSHint
|
||||||
default:
|
default:
|
||||||
this._fireAction(this._prependSlash(key),
|
this._fireAction(this._prependSlash(key),
|
||||||
this._revisionActions[key], true);
|
this._revisionActions[key], true);
|
||||||
@@ -261,7 +261,7 @@
|
|||||||
return function() {
|
return function() {
|
||||||
buttonEl.removeAttribute('loading');
|
buttonEl.removeAttribute('loading');
|
||||||
buttonEl.disabled = false;
|
buttonEl.disabled = false;
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
_fireAction: function(endpoint, action, revAction, opt_payload) {
|
_fireAction: function(endpoint, action, revAction, opt_payload) {
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ limitations under the License.
|
|||||||
<script>
|
<script>
|
||||||
suite('gr-change-actions tests', function() {
|
suite('gr-change-actions tests', function() {
|
||||||
var element;
|
var element;
|
||||||
var response = {
|
|
||||||
ok: true,
|
|
||||||
};
|
|
||||||
setup(function() {
|
setup(function() {
|
||||||
stub('gr-rest-api-interface', {
|
stub('gr-rest-api-interface', {
|
||||||
getChangeRevisionActions: function() {
|
getChangeRevisionActions: function() {
|
||||||
@@ -202,7 +199,8 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
suite('revert change', function() {
|
suite('revert change', function() {
|
||||||
var alertStub, fireActionStub;
|
var alertStub;
|
||||||
|
var fireActionStub;
|
||||||
|
|
||||||
setup(function() {
|
setup(function() {
|
||||||
fireActionStub = sinon.stub(element, '_fireAction');
|
fireActionStub = sinon.stub(element, '_fireAction');
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
var revertCommitText = 'This reverts commit ';
|
var revertCommitText = 'This reverts commit ';
|
||||||
// Selector for previous revert text and commit.
|
// Selector for previous revert text and commit.
|
||||||
var previousRevertText =
|
var previousRevertText =
|
||||||
new RegExp('\n{1,2}' + revertCommitText + '\\w+.\n*', 'gm')
|
new RegExp('\n{1,2}' + revertCommitText + '\\w+.\n*', 'gm');
|
||||||
commitMessage = commitMessage.replace(previousRevertText, '');
|
commitMessage = commitMessage.replace(previousRevertText, '');
|
||||||
this.message = 'Revert "' + commitMessage + '"\n\n' +
|
this.message = 'Revert "' + commitMessage + '"\n\n' +
|
||||||
revertCommitText + commitInfo.commit + '.';
|
revertCommitText + commitInfo.commit + '.';
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ limitations under the License.
|
|||||||
__path: 'tags.html',
|
__path: 'tags.html',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
getChangeFilesStub.restore();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -87,7 +88,7 @@ limitations under the License.
|
|||||||
{__path: 'file_added_in_rev2.txt'},
|
{__path: 'file_added_in_rev2.txt'},
|
||||||
{__path: 'myfile.txt'},
|
{__path: 'myfile.txt'},
|
||||||
];
|
];
|
||||||
element.changeNum = '42',
|
element.changeNum = '42';
|
||||||
element.patchNum = '2';
|
element.patchNum = '2';
|
||||||
element.selectedIndex = 0;
|
element.selectedIndex = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
return {
|
return {
|
||||||
O: options,
|
O: options,
|
||||||
q: query
|
q: query
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeSameTopicQueryParams: function(topic) {
|
_computeSameTopicQueryParams: function(topic) {
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
} else if (change.submittable) {
|
} else if (change.submittable) {
|
||||||
return 'Submittable';
|
return 'Submittable';
|
||||||
}
|
}
|
||||||
return ''
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
_serverConfigChanged: function(config) {
|
_serverConfigChanged: function(config) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
function loadUser(ctx, next) {
|
function loadUser(ctx, next) {
|
||||||
restAPI.getLoggedIn().then(function() {
|
restAPI.getLoggedIn().then(function() {
|
||||||
next();
|
next();
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Routes.
|
// Routes.
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
element._change = {
|
element._change = {
|
||||||
revisions: {
|
revisions: {
|
||||||
a: { _number: 10, },
|
a: {_number: 10},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];
|
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];
|
||||||
@@ -125,7 +125,7 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
element._change = {
|
element._change = {
|
||||||
revisions: {
|
revisions: {
|
||||||
a: { _number: 10, },
|
a: {_number: 10},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];
|
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];
|
||||||
@@ -179,8 +179,8 @@ limitations under the License.
|
|||||||
};
|
};
|
||||||
element._change = {
|
element._change = {
|
||||||
revisions: {
|
revisions: {
|
||||||
a: { _number: 1, },
|
a: {_number: 1},
|
||||||
b: { _number: 2, },
|
b: {_number: 2},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];
|
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
pairs[i].right));
|
pairs[i].right));
|
||||||
}
|
}
|
||||||
this._outputEl.insertBefore(sectionEl, opt_beforeSection);
|
this._outputEl.insertBefore(sectionEl, opt_beforeSection);
|
||||||
},
|
};
|
||||||
|
|
||||||
GrDiffBuilderSideBySide.prototype._createRow = function(section, leftLine,
|
GrDiffBuilderSideBySide.prototype._createRow = function(section, leftLine,
|
||||||
rightLine) {
|
rightLine) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
GrDiffBuilder.prototype.emitGroup = function(group, opt_beforeSection) {
|
GrDiffBuilder.prototype.emitGroup = function(group, opt_beforeSection) {
|
||||||
throw Error('Subclasses must implement emitGroup');
|
throw Error('Subclasses must implement emitGroup');
|
||||||
},
|
};
|
||||||
|
|
||||||
GrDiffBuilder.prototype._processContent = function(content, groups, context) {
|
GrDiffBuilder.prototype._processContent = function(content, groups, context) {
|
||||||
this._appendFileComments(groups);
|
this._appendFileComments(groups);
|
||||||
@@ -339,8 +339,8 @@
|
|||||||
function byLineNum(lineNum) {
|
function byLineNum(lineNum) {
|
||||||
return function(c) {
|
return function(c) {
|
||||||
return (c.line === lineNum) ||
|
return (c.line === lineNum) ||
|
||||||
(c.line === undefined && lineNum === GrDiffLine.FILE)
|
(c.line === undefined && lineNum === GrDiffLine.FILE);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
var leftComments =
|
var leftComments =
|
||||||
comments[GrDiffBuilder.Side.LEFT].filter(byLineNum(line.beforeNumber));
|
comments[GrDiffBuilder.Side.LEFT].filter(byLineNum(line.beforeNumber));
|
||||||
@@ -373,7 +373,7 @@
|
|||||||
threadEl.side = side;
|
threadEl.side = side;
|
||||||
threadEl.projectConfig = projectConfig;
|
threadEl.projectConfig = projectConfig;
|
||||||
return threadEl;
|
return threadEl;
|
||||||
},
|
};
|
||||||
|
|
||||||
GrDiffBuilder.prototype._commentThreadForLine = function(line, opt_side) {
|
GrDiffBuilder.prototype._commentThreadForLine = function(line, opt_side) {
|
||||||
var comments = this._getCommentsForLine(this._comments, line, opt_side);
|
var comments = this._getCommentsForLine(this._comments, line, opt_side);
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ limitations under the License.
|
|||||||
line.beforeNumber = 3;
|
line.beforeNumber = 3;
|
||||||
line.afterNumber = 5;
|
line.afterNumber = 5;
|
||||||
|
|
||||||
var comments = {left: [], right:[]};
|
var comments = {left: [], right: []};
|
||||||
assert.deepEqual(builder._getCommentsForLine(comments, line), []);
|
assert.deepEqual(builder._getCommentsForLine(comments, line), []);
|
||||||
assert.deepEqual(builder._getCommentsForLine(comments, line,
|
assert.deepEqual(builder._getCommentsForLine(comments, line,
|
||||||
GrDiffBuilder.Side.LEFT), []);
|
GrDiffBuilder.Side.LEFT), []);
|
||||||
@@ -328,7 +328,7 @@ limitations under the License.
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
function checkThreadProps(patchNum, side, comments) {
|
function checkThreadProps(threadEl, patchNum, side, comments) {
|
||||||
assert.equal(threadEl.changeNum, '42');
|
assert.equal(threadEl.changeNum, '42');
|
||||||
assert.equal(threadEl.patchNum, patchNum);
|
assert.equal(threadEl.patchNum, patchNum);
|
||||||
assert.equal(threadEl.path, '/path/to/foo');
|
assert.equal(threadEl.path, '/path/to/foo');
|
||||||
@@ -340,27 +340,27 @@ limitations under the License.
|
|||||||
var line = new GrDiffLine(GrDiffLine.Type.BOTH);
|
var line = new GrDiffLine(GrDiffLine.Type.BOTH);
|
||||||
line.beforeNumber = 5;
|
line.beforeNumber = 5;
|
||||||
line.afterNumber = 5;
|
line.afterNumber = 5;
|
||||||
threadEl = builder._commentThreadForLine(line);
|
var threadEl = builder._commentThreadForLine(line);
|
||||||
checkThreadProps('3', 'REVISION',
|
checkThreadProps(threadEl, '3', 'REVISION',
|
||||||
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
|
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
|
||||||
|
|
||||||
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.RIGHT);
|
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.RIGHT);
|
||||||
checkThreadProps('3', 'REVISION', [{id: 'r5', line: 5}]);
|
checkThreadProps(threadEl, '3', 'REVISION', [{id: 'r5', line: 5}]);
|
||||||
|
|
||||||
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.LEFT);
|
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.LEFT);
|
||||||
checkThreadProps('3', 'PARENT', [{id: 'l5', line: 5}]);
|
checkThreadProps(threadEl, '3', 'PARENT', [{id: 'l5', line: 5}]);
|
||||||
|
|
||||||
builder._comments.meta.patchRange.basePatchNum = '1';
|
builder._comments.meta.patchRange.basePatchNum = '1';
|
||||||
|
|
||||||
threadEl = builder._commentThreadForLine(line);
|
threadEl = builder._commentThreadForLine(line);
|
||||||
checkThreadProps('3', 'REVISION',
|
checkThreadProps(threadEl, '3', 'REVISION',
|
||||||
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
|
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
|
||||||
|
|
||||||
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.LEFT);
|
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.LEFT);
|
||||||
checkThreadProps('1', 'REVISION', [{id: 'l5', line: 5}]);
|
checkThreadProps(threadEl, '1', 'REVISION', [{id: 'l5', line: 5}]);
|
||||||
|
|
||||||
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.RIGHT);
|
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.RIGHT);
|
||||||
checkThreadProps('3', 'REVISION', [{id: 'r5', line: 5}]);
|
checkThreadProps(threadEl, '3', 'REVISION', [{id: 'r5', line: 5}]);
|
||||||
|
|
||||||
builder._comments.meta.patchRange.basePatchNum = 'PARENT';
|
builder._comments.meta.patchRange.basePatchNum = 'PARENT';
|
||||||
|
|
||||||
@@ -368,14 +368,14 @@ limitations under the License.
|
|||||||
line.beforeNumber = 5;
|
line.beforeNumber = 5;
|
||||||
line.afterNumber = 5;
|
line.afterNumber = 5;
|
||||||
threadEl = builder._commentThreadForLine(line);
|
threadEl = builder._commentThreadForLine(line);
|
||||||
checkThreadProps('3', 'PARENT',
|
checkThreadProps(threadEl, '3', 'PARENT',
|
||||||
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
|
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
|
||||||
|
|
||||||
line = new GrDiffLine(GrDiffLine.Type.ADD);
|
line = new GrDiffLine(GrDiffLine.Type.ADD);
|
||||||
line.beforeNumber = 3;
|
line.beforeNumber = 3;
|
||||||
line.afterNumber = 5;
|
line.afterNumber = 5;
|
||||||
threadEl = builder._commentThreadForLine(line);
|
threadEl = builder._commentThreadForLine(line);
|
||||||
checkThreadProps('3', 'REVISION',
|
checkThreadProps(threadEl, '3', 'REVISION',
|
||||||
[{id: 'l3', line: 3}, {id: 'r5', line: 5}]);
|
[{id: 'l3', line: 3}, {id: 'r5', line: 5}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@
|
|||||||
break;
|
break;
|
||||||
case DiffViewMode.SIDE_BY_SIDE:
|
case DiffViewMode.SIDE_BY_SIDE:
|
||||||
classes.push('sideBySide');
|
classes.push('sideBySide');
|
||||||
break
|
break;
|
||||||
default:
|
default:
|
||||||
throw Error('Invalid view mode: ', viewMode);
|
throw Error('Invalid view mode: ', viewMode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ limitations under the License.
|
|||||||
setup(function() {
|
setup(function() {
|
||||||
stub('gr-rest-api-interface', {
|
stub('gr-rest-api-interface', {
|
||||||
getLoggedIn: function() { return Promise.resolve(false); },
|
getLoggedIn: function() { return Promise.resolve(false); },
|
||||||
})
|
});
|
||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -46,18 +46,21 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('dom for existing account', function() {
|
test('dom for existing account', function() {
|
||||||
assert.isTrue(element.hasAttribute('hidden'), 'element not hidden initially');
|
assert.isTrue(element.hasAttribute('hidden'),
|
||||||
|
'element not hidden initially');
|
||||||
element.hidden = false;
|
element.hidden = false;
|
||||||
element.imageSize = 64;
|
element.imageSize = 64;
|
||||||
element.account = {
|
element.account = {
|
||||||
_account_id: 123
|
_account_id: 123
|
||||||
};
|
};
|
||||||
assert.isFalse(element.hasAttribute('hidden'), 'element hidden');
|
assert.isFalse(element.hasAttribute('hidden'), 'element hidden');
|
||||||
assert.isTrue(element.style.backgroundImage.indexOf('/accounts/123/avatar?s=64') > -1);
|
assert.isTrue(element.style.backgroundImage.indexOf(
|
||||||
|
'/accounts/123/avatar?s=64') > -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('dom for non available account', function() {
|
test('dom for non available account', function() {
|
||||||
assert.isTrue(element.hasAttribute('hidden'), 'element not hidden initially');
|
assert.isTrue(element.hasAttribute('hidden'),
|
||||||
|
'element not hidden initially');
|
||||||
element.account = undefined;
|
element.account = undefined;
|
||||||
assert.isTrue(element.hasAttribute('hidden'), 'element not hidden');
|
assert.isTrue(element.hasAttribute('hidden'), 'element not hidden');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
_handleShowChange: function(detail) {
|
_handleShowChange: function(detail) {
|
||||||
this._getEventCallbacks(EventType.SHOW_CHANGE).forEach(function(cb) {
|
this._getEventCallbacks(EventType.SHOW_CHANGE).forEach(function(cb) {
|
||||||
var change = detail.change;
|
var change = detail.change;
|
||||||
var patchNum = detail.patchNum
|
var patchNum = detail.patchNum;
|
||||||
var revision;
|
var revision;
|
||||||
for (var rev in change.revisions) {
|
for (var rev in change.revisions) {
|
||||||
if (change.revisions[rev]._number == patchNum) {
|
if (change.revisions[rev]._number == patchNum) {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ limitations under the License.
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('comment event', function(done) {
|
test('comment event', function(done) {
|
||||||
var testCommentNode = { foo: 'bar' };
|
var testCommentNode = {foo: 'bar'};
|
||||||
plugin.on(element.EventType.COMMENT, function(commentNode) {
|
plugin.on(element.EventType.COMMENT, function(commentNode) {
|
||||||
assert.deepEqual(commentNode, testCommentNode);
|
assert.deepEqual(commentNode, testCommentNode);
|
||||||
done();
|
done();
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ limitations under the License.
|
|||||||
fetchJSONStub.restore();
|
fetchJSONStub.restore();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
resolveFetchJSON({rebase:{}});
|
resolveFetchJSON({rebase: {}});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user