Don’t require fourslash completions tests to specify replacementSpan when it’s zero-length (#42013)

This commit is contained in:
Andrew Branch
2020-12-17 09:45:49 -08:00
committed by GitHub
parent c73e4805cc
commit 3160b5cfcc
2 changed files with 9 additions and 10 deletions

View File

@@ -907,11 +907,13 @@ namespace FourSlash {
this.raiseError(`Expected completion insert text to be ${expected.insertText}, got ${actual.insertText}`);
}
const convertedReplacementSpan = expected.replacementSpan && ts.createTextSpanFromRange(expected.replacementSpan);
try {
assert.deepEqual(actual.replacementSpan, convertedReplacementSpan);
}
catch {
this.raiseError(`Expected completion replacementSpan to be ${stringify(convertedReplacementSpan)}, got ${stringify(actual.replacementSpan)}`);
if (convertedReplacementSpan?.length) {
try {
assert.deepEqual(actual.replacementSpan, convertedReplacementSpan);
}
catch {
this.raiseError(`Expected completion replacementSpan to be ${stringify(convertedReplacementSpan)}, got ${stringify(actual.replacementSpan)}`);
}
}
if (expected.kind !== undefined || expected.kindModifiers !== undefined) {

View File

@@ -2,12 +2,9 @@
// @strict: true
//// declare function get<T, K extends keyof T>(obj: T, key: K): T[K];
//// get({ hello: 123, world: 456 }, "[|/**/|]");
//// get({ hello: 123, world: 456 }, "/**/");
verify.completions({
marker: "",
includes: [
{ name: 'hello', replacementSpan: test.ranges()[0] },
{ name: 'world', replacementSpan: test.ranges()[0] }
]
includes: ["hello", "world"]
});