Skip to content

Commit 0880610

Browse files
committed
make format test more meaningful
1 parent 5fc1234 commit 0880610

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

typescript/test/completions.spec.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,24 +506,28 @@ test('In Keyword Completions', () => {
506506
test('Format ignore', () => {
507507
decorateFormatFeatures(languageService, { ...languageService }, defaultConfigFunc)
508508
const [pos] = newFileContents(/* ts */ `
509-
const a = {
510-
//@ts-format-ignore-region
511-
a: 1,
512-
a1: 2,
513-
//@ts-format-ignore-endregion
514-
b: 3,
515-
//@ts-format-ignore-line
516-
c: 4,
517-
}
518-
`)
519-
const edits = languageService.getFormattingEditsForRange(entrypoint, 0, files[entrypoint]!.length, {}).filter(x => !!x.newText)
509+
const a = {
510+
//@ts-format-ignore-region
511+
a: 1,
512+
a1: 2,
513+
//@ts-format-ignore-endregion
514+
b: 3,
515+
//@ts-format-ignore-line
516+
c: 4,
517+
}`)
518+
const edits = languageService.getFormattingEditsForRange(entrypoint, 0, files[entrypoint]!.length, ts.getDefaultFormatCodeSettings())
519+
// const sourceFile = languageService.getProgram()!.getSourceFile(entrypoint)!
520+
// const text = sourceFile.getFullText()
521+
// edits.forEach(edit => {
522+
// console.log(text.slice(0, edit.span.start) + '<<<' + edit.newText + '>>>' + text.slice(edit.span.start + edit.span.length))
523+
// })
520524
expect(edits).toMatchInlineSnapshot(/* json */ `
521525
[
522526
{
523527
"newText": " ",
524528
"span": {
525529
"length": 2,
526-
"start": 134,
530+
"start": 108,
527531
},
528532
},
529533
]

0 commit comments

Comments
 (0)