Add tests for shift-clicking in wordwise and linewise mode

This commit is contained in:
Nathan Sobo 2017-03-10 10:36:51 -07:00 committed by Antonio Scandurra
parent e92cf0fe70
commit 4ef9d385f3

View File

@ -786,6 +786,38 @@ describe('TextEditorComponent', () => {
shiftKey: true
}, clientPositionForCharacter(component, 4, 4)))
expect(editor.getSelectedScreenRange()).toEqual([[2, 18], [4, 4]])
// reorients word-wise selections to keep the word selected regardless of
// where the subsequent shift-click occurs
editor.setCursorScreenPosition([2, 18])
editor.getLastSelection().selectWord()
component.didMouseDownOnContent(Object.assign({
detail: 1,
shiftKey: true
}, clientPositionForCharacter(component, 1, 4)))
expect(editor.getSelectedScreenRange()).toEqual([[1, 2], [2, 20]])
component.didMouseDownOnContent(Object.assign({
detail: 1,
shiftKey: true
}, clientPositionForCharacter(component, 3, 11)))
expect(editor.getSelectedScreenRange()).toEqual([[2, 14], [3, 13]])
// reorients line-wise selections to keep the word selected regardless of
// where the subsequent shift-click occurs
editor.setCursorScreenPosition([2, 18])
editor.getLastSelection().selectLine()
component.didMouseDownOnContent(Object.assign({
detail: 1,
shiftKey: true
}, clientPositionForCharacter(component, 1, 4)))
expect(editor.getSelectedScreenRange()).toEqual([[1, 0], [3, 0]])
component.didMouseDownOnContent(Object.assign({
detail: 1,
shiftKey: true
}, clientPositionForCharacter(component, 3, 11)))
expect(editor.getSelectedScreenRange()).toEqual([[2, 0], [4, 0]])
})
})
})