-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Showing
2 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
src/vs/editor/contrib/suggest/test/common/completionModel.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,72 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
import * as assert from 'assert'; | ||
import {ISuggestResult2} from 'vs/editor/contrib/suggest/common/suggest'; | ||
import {CompletionModel, CompletionItemComparator} from 'vs/editor/contrib/suggest/common/completionModel'; | ||
|
||
|
||
const mixedSuggestions = <ISuggestResult2>{ | ||
currentWord: '', | ||
incomplete: false, | ||
support: undefined, | ||
suggestions: [{ | ||
type: 'snippet', | ||
label: 'zzz', | ||
codeSnippet: 'zzz' | ||
}, { | ||
type: 'snippet', | ||
label: 'aaa', | ||
codeSnippet: 'aaa' | ||
}, { | ||
type: 'property', | ||
label: 'fff', | ||
codeSnippet: 'fff' | ||
}] | ||
}; | ||
|
||
|
||
suite('CompletionModel', function() { | ||
|
||
test('sort - normal', function() { | ||
const model = new CompletionModel([mixedSuggestions], '', CompletionItemComparator.defaultComparator, false); | ||
assert.equal(model.items.length, 3); | ||
|
||
const [one, two, three] = model.items; | ||
assert.equal(one.suggestion.label, 'aaa'); | ||
assert.equal(two.suggestion.label, 'fff'); | ||
assert.equal(three.suggestion.label, 'zzz'); | ||
}); | ||
|
||
test('sort - snippet up', function() { | ||
const model = new CompletionModel([mixedSuggestions], '', CompletionItemComparator.snippetUpComparator, false); | ||
assert.equal(model.items.length, 3); | ||
|
||
const [one, two, three] = model.items; | ||
assert.equal(one.suggestion.label, 'aaa'); | ||
assert.equal(two.suggestion.label, 'zzz'); | ||
assert.equal(three.suggestion.label, 'fff'); | ||
}); | ||
|
||
test('sort - snippet down', function() { | ||
const model = new CompletionModel([mixedSuggestions], '', CompletionItemComparator.snippetDownComparator, false); | ||
assert.equal(model.items.length, 3); | ||
|
||
const [one, two, three] = model.items; | ||
assert.equal(one.suggestion.label, 'fff'); | ||
assert.equal(two.suggestion.label, 'aaa'); | ||
assert.equal(three.suggestion.label, 'zzz'); | ||
}); | ||
|
||
test('ignore snippets', function() { | ||
|
||
const model = new CompletionModel([mixedSuggestions], '', CompletionItemComparator.defaultComparator, true); | ||
assert.equal(model.items.length, 1); | ||
|
||
const [one] = model.items; | ||
assert.equal(one.suggestion.label, 'fff'); | ||
}); | ||
}); |