1- import { describe , expect } from 'vitest ' ;
2- import packageJson from 'node_modules/ typescript/package.json' assert { type : 'json' } ;
3- import { getCurrentTsVersion , loadTargetConfig } from "./utils.js" ;
4- import * as tsModule from "typescript" ;
1+ import packageJson from 'node_modules/typescript/package.json ' ;
2+ import * as tsModule from 'typescript' ;
3+ import { describe , expect } from 'vitest' ;
4+ import { getCurrentTsVersion , loadTargetConfig } from './utils.js' ;
55
66describe ( 'getCurrentTsVersion' , ( ) => {
77 it ( 'should return currently installed TypeScript version as semver string' , async ( ) => {
@@ -10,37 +10,53 @@ describe('getCurrentTsVersion', () => {
1010} ) ;
1111
1212describe ( 'loadTargetConfig' , ( ) => {
13- const parseConfigFileTextToJsonSpy = vi . spyOn ( tsModule , 'parseConfigFileTextToJson' ) ;
14- const parseJsonConfigFileContentSpy = vi . spyOn ( tsModule , 'parseJsonConfigFileContent' ) ;
13+ const parseConfigFileTextToJsonSpy = vi . spyOn (
14+ tsModule ,
15+ 'parseConfigFileTextToJson' ,
16+ ) ;
17+ const parseJsonConfigFileContentSpy = vi . spyOn (
18+ tsModule ,
19+ 'parseJsonConfigFileContent' ,
20+ ) ;
1521
1622 it ( 'should return the parsed content of a tsconfig file and ist TypeScript helper to parse it' , async ( ) => {
17- await expect ( loadTargetConfig ( 'packages/plugin-typescript/mocks/fixtures/tsconfig.init.json' ) ) . resolves
18- . toStrictEqual ( expect . objectContaining ( {
19- fileNames : expect . any ( Array ) ,
20- options : {
21- module : 1 ,
22- configFilePath : undefined ,
23- esModuleInterop : true ,
24- forceConsistentCasingInFileNames : true ,
25- skipLibCheck : true ,
26- strict : true ,
27- target : 3
28- }
29- } )
30- ) ;
23+ await expect (
24+ loadTargetConfig (
25+ 'packages/plugin-typescript/mocks/fixtures/tsconfig.init.json' ,
26+ ) ,
27+ ) . resolves . toStrictEqual (
28+ expect . objectContaining ( {
29+ fileNames : expect . any ( Array ) ,
30+ options : {
31+ module : 1 ,
32+ configFilePath : undefined ,
33+ esModuleInterop : true ,
34+ forceConsistentCasingInFileNames : true ,
35+ skipLibCheck : true ,
36+ strict : true ,
37+ target : 3 ,
38+ } ,
39+ } ) ,
40+ ) ;
3141 expect ( parseConfigFileTextToJsonSpy ) . toHaveBeenCalledTimes ( 1 ) ;
32- expect ( parseConfigFileTextToJsonSpy ) . toHaveBeenCalledWith ( "packages/plugin-typescript/mocks/fixtures/tsconfig.init.json" , expect . stringContaining ( '/* Projects */' ) ) ;
42+ expect ( parseConfigFileTextToJsonSpy ) . toHaveBeenCalledWith (
43+ 'packages/plugin-typescript/mocks/fixtures/tsconfig.init.json' ,
44+ expect . stringContaining ( '/* Projects */' ) ,
45+ ) ;
3346 expect ( parseJsonConfigFileContentSpy ) . toHaveBeenCalledTimes ( 1 ) ;
34- expect ( parseJsonConfigFileContentSpy ) . toHaveBeenCalledWith ( expect . objectContaining ( {
35- compilerOptions : expect . objectContaining ( {
36- esModuleInterop : true ,
37- forceConsistentCasingInFileNames : true ,
38- module : "commonjs" ,
39- skipLibCheck : true ,
40- strict : true ,
41- target : "es2016" ,
42- } )
43- } ) , expect . any ( Object ) , expect . any ( String ) ) ;
47+ expect ( parseJsonConfigFileContentSpy ) . toHaveBeenCalledWith (
48+ expect . objectContaining ( {
49+ compilerOptions : expect . objectContaining ( {
50+ esModuleInterop : true ,
51+ forceConsistentCasingInFileNames : true ,
52+ module : 'commonjs' ,
53+ skipLibCheck : true ,
54+ strict : true ,
55+ target : 'es2016' ,
56+ } ) ,
57+ } ) ,
58+ expect . any ( Object ) ,
59+ expect . any ( String ) ,
60+ ) ;
4461 } ) ;
45-
4662} ) ;
0 commit comments