38 lines
1.7 KiB
TypeScript
38 lines
1.7 KiB
TypeScript
|
|
import * as assert from 'assert';
|
||
|
|
import { BuiltInCompletion } from '../../providers/completions/BuiltInCompletion';
|
||
|
|
import { SnippetCompletion } from '../../providers/completions/SnippetCompletion';
|
||
|
|
|
||
|
|
suite('Completion Provider Test Suite', () => {
|
||
|
|
test('BuiltInCompletion: Reagiert auf "log."', () => {
|
||
|
|
const strategy = new BuiltInCompletion();
|
||
|
|
// Wir faken Document und Position, da wir nur linePrefix brauchen
|
||
|
|
const result = strategy.provideCompletions(null as any, null as any, ' log.');
|
||
|
|
|
||
|
|
assert.ok(result !== undefined);
|
||
|
|
assert.strictEqual(result.length, 4); // debug, info, warn, error
|
||
|
|
assert.strictEqual(result[0].label, 'debug');
|
||
|
|
});
|
||
|
|
|
||
|
|
test('BuiltInCompletion: Ignoriert normalen Text', () => {
|
||
|
|
const strategy = new BuiltInCompletion();
|
||
|
|
const result = strategy.provideCompletions(null as any, null as any, ' my_var');
|
||
|
|
|
||
|
|
assert.strictEqual(result, undefined);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('SnippetCompletion: Liefert Snippets für normalen Text', () => {
|
||
|
|
const strategy = new SnippetCompletion();
|
||
|
|
const result = strategy.provideCompletions(null as any, null as any, ' i');
|
||
|
|
|
||
|
|
assert.ok(result !== undefined);
|
||
|
|
const hasIf = result.some(item => item.label === 'if');
|
||
|
|
assert.ok(hasIf, "Muss 'if' Snippet vorschlagen");
|
||
|
|
});
|
||
|
|
|
||
|
|
test('SnippetCompletion: Blockiert Snippets nach Punkt', () => {
|
||
|
|
const strategy = new SnippetCompletion();
|
||
|
|
const result = strategy.provideCompletions(null as any, null as any, ' discovery.r');
|
||
|
|
|
||
|
|
assert.strictEqual(result, undefined, "Darf keine Block-Snippets in Namespaces anzeigen");
|
||
|
|
});
|
||
|
|
});
|