11import { readdirSync , readFileSync , lstatSync } from "fs"
22import { join , extname , parse } from "path"
33import { toMatchFile } from "jest-file-snapshot"
4- import { twoslasher } from "../src/index"
4+ import { twoslasher , TwoSlashReturn } from "../src/index"
55import { format } from "prettier"
66
77expect . extend ( { toMatchFile } )
@@ -28,7 +28,7 @@ describe("with fixtures", () => {
2828 const file = readFileSync ( fixture , "utf8" )
2929
3030 const fourslashed = twoslasher ( file , extname ( fixtureName ) . substr ( 1 ) )
31- const jsonString = format ( JSON . stringify ( fourslashed ) , { parser : "json" } )
31+ const jsonString = format ( JSON . stringify ( cleanFixture ( fourslashed ) ) , { parser : "json" } )
3232 expect ( jsonString ) . toMatchFile ( result )
3333 } )
3434 } )
@@ -47,7 +47,7 @@ describe("with fixtures", () => {
4747 const file = readFileSync ( fixture , "utf8" )
4848
4949 const fourslashed = twoslasher ( file , extname ( fixtureName ) . substr ( 1 ) )
50- const jsonString = format ( JSON . stringify ( fourslashed ) , { parser : "json" } )
50+ const jsonString = format ( JSON . stringify ( cleanFixture ( fourslashed ) ) , { parser : "json" } )
5151 expect ( jsonString ) . toMatchFile ( result )
5252 } )
5353 } )
@@ -66,7 +66,7 @@ describe("with fixtures", () => {
6666 const file = readFileSync ( fixture , "utf8" )
6767
6868 const fourslashed = twoslasher ( file , extname ( fixtureName ) . substr ( 1 ) )
69- const jsonString = format ( JSON . stringify ( fourslashed ) , { parser : "json" } )
69+ const jsonString = format ( JSON . stringify ( cleanFixture ( fourslashed ) ) , { parser : "json" } )
7070 expect ( jsonString ) . toMatchFile ( result )
7171 } )
7272 } )
@@ -97,3 +97,11 @@ describe("with fixtures", () => {
9797 } )
9898 } )
9999} )
100+
101+ const cleanFixture = ( ts : TwoSlashReturn ) => {
102+ const wd = process . cwd ( )
103+ ts . staticQuickInfos . forEach ( info => {
104+ info . text = info . text . replace ( new RegExp ( wd , "g" ) , "[home]" )
105+ } )
106+ return ts
107+ }
0 commit comments