Fix custom event to recompute diff cursor stops on context show
Bug: Issue 6188 Change-Id: If038b2e7dc9c070e69eb5264a94ea707f4847c46
This commit is contained in:
@@ -241,7 +241,7 @@ limitations under the License.
|
||||
sectionEl.parentNode.removeChild(sectionEl);
|
||||
|
||||
this.async(function() {
|
||||
this.fire('render');
|
||||
this.fire('render-content');
|
||||
}, 1);
|
||||
},
|
||||
|
||||
|
||||
@@ -371,7 +371,8 @@
|
||||
i++) {
|
||||
this.unlisten(splice.removed[i],
|
||||
'render-start', '_handleDiffRenderStart');
|
||||
this.unlisten(splice.removed[i], 'render', 'handleDiffUpdate');
|
||||
this.unlisten(splice.removed[i],
|
||||
'render-content', 'handleDiffUpdate');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -39,11 +39,14 @@ limitations under the License.
|
||||
|
||||
<script>
|
||||
suite('gr-diff-cursor tests', function() {
|
||||
var sandbox;
|
||||
var cursorElement;
|
||||
var diffElement;
|
||||
var mockDiffResponse;
|
||||
|
||||
setup(function(done) {
|
||||
sandbox = sinon.sandbox.create();
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getLoggedIn: function() { return Promise.resolve(false); },
|
||||
});
|
||||
@@ -60,32 +63,34 @@ limitations under the License.
|
||||
diffElement.prefs = prefs;
|
||||
});
|
||||
|
||||
sinon.stub(diffElement, '_getDiff', function() {
|
||||
sandbox.stub(diffElement, '_getDiff', function() {
|
||||
return Promise.resolve(mockDiffResponse.diffResponse);
|
||||
});
|
||||
|
||||
sinon.stub(diffElement, '_getDiffComments', function() {
|
||||
sandbox.stub(diffElement, '_getDiffComments', function() {
|
||||
return Promise.resolve({baseComments: [], comments: []});
|
||||
});
|
||||
|
||||
sinon.stub(diffElement, '_getDiffDrafts', function() {
|
||||
sandbox.stub(diffElement, '_getDiffDrafts', function() {
|
||||
return Promise.resolve({baseComments: [], comments: []});
|
||||
});
|
||||
|
||||
sinon.stub(diffElement, '_getDiffRobotComments', function() {
|
||||
sandbox.stub(diffElement, '_getDiffRobotComments', function() {
|
||||
return Promise.resolve({baseComments: [], comments: []});
|
||||
});
|
||||
|
||||
var setupDone = function() {
|
||||
cursorElement.moveToFirstChunk();
|
||||
done();
|
||||
diffElement.removeEventListener('render', setupDone);
|
||||
done();
|
||||
};
|
||||
diffElement.addEventListener('render', setupDone);
|
||||
|
||||
diffElement.reload();
|
||||
});
|
||||
|
||||
teardown(() => { sandbox.restore(); });
|
||||
|
||||
test('diff cursor functionality (side-by-side)', function() {
|
||||
// The cursor has been initialized to the first delta.
|
||||
assert.isOk(cursorElement.diffRow);
|
||||
@@ -211,8 +216,8 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('initialLineNumber disabled', function(done) {
|
||||
var moveToNumStub = sinon.stub(cursorElement, 'moveToLineNumber');
|
||||
var moveToChunkStub = sinon.stub(cursorElement, 'moveToFirstChunk');
|
||||
var moveToNumStub = sandbox.stub(cursorElement, 'moveToLineNumber');
|
||||
var moveToChunkStub = sandbox.stub(cursorElement, 'moveToFirstChunk');
|
||||
|
||||
diffElement.addEventListener('render', function() {
|
||||
assert.isFalse(moveToNumStub.called);
|
||||
@@ -224,8 +229,8 @@ limitations under the License.
|
||||
});
|
||||
|
||||
test('initialLineNumber enabled', function(done) {
|
||||
var moveToNumStub = sinon.stub(cursorElement, 'moveToLineNumber');
|
||||
var moveToChunkStub = sinon.stub(cursorElement, 'moveToFirstChunk');
|
||||
var moveToNumStub = sandbox.stub(cursorElement, 'moveToLineNumber');
|
||||
var moveToChunkStub = sandbox.stub(cursorElement, 'moveToFirstChunk');
|
||||
|
||||
diffElement.addEventListener('render', function() {
|
||||
assert.isFalse(moveToChunkStub.called);
|
||||
@@ -274,5 +279,14 @@ limitations under the License.
|
||||
assert.equal(cursorElement._findRowByNumberAndFile(8, 'right'), row);
|
||||
assert.equal(cursorElement._findRowByNumberAndFile(5, 'left'), row);
|
||||
});
|
||||
|
||||
test('expand context updates stops', done => {
|
||||
sandbox.spy(cursorElement, 'handleDiffUpdate');
|
||||
MockInteractions.tap(diffElement.$$('.showContext'));
|
||||
flush(() => {
|
||||
assert.isTrue(cursorElement.handleDiffUpdate.called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user