-
Notifications
You must be signed in to change notification settings - Fork 28.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36d5e04
commit 5d68db0
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/vs/workbench/services/search/test/common/searchHelpers.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import { ITextModel, FindMatch } from 'vs/editor/common/model'; | ||
import { editorMatchesToTextSearchResults } from 'vs/workbench/services/search/common/searchHelpers'; | ||
import { Range } from 'vs/editor/common/core/range'; | ||
|
||
suite('editorMatchesToTextSearchResults', () => { | ||
const mockTextModel: ITextModel = <ITextModel>{ | ||
getLineContent(lineNumber: number): string { | ||
return '' + lineNumber; | ||
} | ||
}; | ||
|
||
test('simple', () => { | ||
const results = editorMatchesToTextSearchResults([new FindMatch(new Range(6, 1, 6, 2), null)], mockTextModel); | ||
assert.equal(results.length, 1); | ||
assert.equal(results[0].preview.text, '6'); | ||
assert.deepEqual(results[0].preview.matches, [new Range(0, 0, 0, 1)]); | ||
assert.deepEqual(results[0].ranges, [new Range(5, 0, 5, 1)]); | ||
}); | ||
|
||
test('multiple', () => { | ||
const results = editorMatchesToTextSearchResults( | ||
[ | ||
new FindMatch(new Range(6, 1, 6, 2), null), | ||
new FindMatch(new Range(6, 4, 8, 2), null), | ||
new FindMatch(new Range(9, 1, 10, 3), null), | ||
], | ||
mockTextModel); | ||
assert.equal(results.length, 2); | ||
assert.deepEqual(results[0].preview.matches, [ | ||
new Range(0, 0, 0, 1), | ||
new Range(0, 3, 2, 1), | ||
]); | ||
assert.deepEqual(results[0].ranges, [ | ||
new Range(5, 0, 5, 1), | ||
new Range(5, 3, 7, 1), | ||
]); | ||
assert.equal(results[0].preview.text, '6\n7\n8'); | ||
|
||
assert.deepEqual(results[1].preview.matches, [ | ||
new Range(0, 0, 1, 2), | ||
]); | ||
assert.deepEqual(results[1].ranges, [ | ||
new Range(8, 0, 9, 2), | ||
]); | ||
assert.equal(results[1].preview.text, '9\n10'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters