mirror of
https://github.com/Microsoft/vscode
synced 2024-09-19 18:48:00 +00:00
Bring back complete tests (including selection assertion)
This commit is contained in:
parent
512287f7f6
commit
e6781fd115
|
@ -95,12 +95,10 @@
|
|||
"./vs/editor/contrib/indentation/indentation.ts",
|
||||
"./vs/editor/contrib/indentation/test/indentation.test.ts",
|
||||
"./vs/editor/contrib/linesOperations/copyLinesCommand.ts",
|
||||
"./vs/editor/contrib/linesOperations/deleteLinesCommand.ts",
|
||||
"./vs/editor/contrib/linesOperations/linesOperations.ts",
|
||||
"./vs/editor/contrib/linesOperations/moveLinesCommand.ts",
|
||||
"./vs/editor/contrib/linesOperations/sortLinesCommand.ts",
|
||||
"./vs/editor/contrib/linesOperations/test/copyLinesCommand.test.ts",
|
||||
"./vs/editor/contrib/linesOperations/test/deleteLinesCommand.test.ts",
|
||||
"./vs/editor/contrib/linesOperations/test/linesOperations.test.ts",
|
||||
"./vs/editor/contrib/linesOperations/test/moveLinesCommand.test.ts",
|
||||
"./vs/editor/contrib/linesOperations/test/sortLinesCommand.test.ts",
|
||||
|
|
|
@ -900,174 +900,191 @@ suite('Editor Contrib - Line Operations', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('empty selection in middle of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(2, 3, 2, 3)
|
||||
]);
|
||||
function testDeleteLinesCommand(initialText: string[], initialSelection: Selection, resultingText: string[], resultingSelection: Selection): void {
|
||||
withTestCodeEditor(initialText, {}, (editor) => {
|
||||
editor.setSelection(initialSelection);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'first\nthird line\nfourth line\nfifth');
|
||||
assert.equal(editor.getValue(), resultingText.join('\n'));
|
||||
assert.deepEqual(editor.getSelection(), resultingSelection);
|
||||
});
|
||||
}
|
||||
|
||||
test('empty selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 3, 2, 3),
|
||||
[
|
||||
'first',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 3, 2, 3)
|
||||
);
|
||||
});
|
||||
|
||||
test('empty selection at top of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(1, 5, 1, 5)
|
||||
]);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'second line\nthird line\nfourth line\nfifth');
|
||||
});
|
||||
test('empty selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('empty selection at end of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(5, 2, 5, 2)
|
||||
]);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'first\nsecond line\nthird line\nfourth line');
|
||||
});
|
||||
test('empty selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(5, 2, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line'
|
||||
],
|
||||
new Selection(4, 2, 4, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection in middle of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(3, 3, 2, 2)
|
||||
]);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'first\nfourth line\nfifth');
|
||||
});
|
||||
test('with selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(3, 3, 2, 2),
|
||||
[
|
||||
'first',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 2, 2, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection at top of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(1, 4, 1, 5)
|
||||
]);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'second line\nthird line\nfourth line\nfifth');
|
||||
});
|
||||
test('with selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 4, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection at end of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(5, 1, 5, 2)
|
||||
]);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'first\nsecond line\nthird line\nfourth line');
|
||||
});
|
||||
test('with selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(5, 1, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line'
|
||||
],
|
||||
new Selection(4, 2, 4, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection in middle of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(4, 1, 2, 1)
|
||||
]);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'first\nfourth line\nfifth');
|
||||
});
|
||||
test('with full line selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(4, 1, 2, 1),
|
||||
[
|
||||
'first',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 1, 2, 1)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection at top of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(2, 1, 1, 5)
|
||||
]);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'second line\nthird line\nfourth line\nfifth');
|
||||
});
|
||||
test('with full line selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 1, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection at end of lines', () => {
|
||||
const TEXT = [
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
];
|
||||
withTestCodeEditor(TEXT, {}, (editor) => {
|
||||
editor.setSelections([
|
||||
new Selection(4, 1, 5, 2)
|
||||
]);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), 'first\nsecond line\nthird line');
|
||||
});
|
||||
test('with full line selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(4, 1, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line'
|
||||
],
|
||||
new Selection(3, 2, 3, 2)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue