@@ -90,4 +90,72 @@ suite('WorkspaceConfig', () => {
9090 strictEqual ( wsConfig . get ( 'fmt.experimental' ) , true ) ;
9191 strictEqual ( wsConfig . get ( 'fmt.configPath' ) , './oxfmt.json' ) ;
9292 } ) ;
93+
94+ test ( 'toLanguageServerConfig method' , async ( ) => {
95+ const config = new WorkspaceConfig ( WORKSPACE_FOLDER ) ;
96+
97+ await Promise . all ( [
98+ config . updateRunTrigger ( 'onSave' ) ,
99+ config . updateConfigPath ( './somewhere' ) ,
100+ config . updateTsConfigPath ( './tsconfig.json' ) ,
101+ config . updateUnusedDisableDirectives ( 'deny' ) ,
102+ config . updateTypeAware ( true ) ,
103+ config . updateDisableNestedConfig ( true ) ,
104+ config . updateFixKind ( FixKind . DangerousFix ) ,
105+ config . updateFormattingExperimental ( true ) ,
106+ config . updateFormattingConfigPath ( './oxfmt.json' ) ,
107+ ] ) ;
108+
109+ const lsConfig = config . toLanguageServerConfig ( ) ;
110+
111+ strictEqual ( lsConfig . run , 'onSave' ) ;
112+ strictEqual ( lsConfig . configPath , './somewhere' ) ;
113+ strictEqual ( lsConfig . tsConfigPath , './tsconfig.json' ) ;
114+ strictEqual ( lsConfig . unusedDisableDirectives , 'deny' ) ;
115+ strictEqual ( lsConfig . typeAware , true ) ;
116+ strictEqual ( lsConfig . disableNestedConfig , true ) ;
117+ strictEqual ( lsConfig . fixKind , 'dangerous_fix' ) ;
118+ strictEqual ( lsConfig [ 'fmt.experimental' ] , true ) ;
119+ strictEqual ( lsConfig [ 'fmt.configPath' ] , './oxfmt.json' ) ;
120+ } ) ;
121+
122+ test ( 'toOxlintConfig method' , async ( ) => {
123+ const config = new WorkspaceConfig ( WORKSPACE_FOLDER ) ;
124+
125+ await Promise . all ( [
126+ config . updateRunTrigger ( 'onSave' ) ,
127+ config . updateConfigPath ( './somewhere' ) ,
128+ config . updateTsConfigPath ( './tsconfig.json' ) ,
129+ config . updateUnusedDisableDirectives ( 'deny' ) ,
130+ config . updateTypeAware ( true ) ,
131+ config . updateDisableNestedConfig ( true ) ,
132+ config . updateFixKind ( FixKind . DangerousFix ) ,
133+ config . updateFormattingExperimental ( true ) ,
134+ config . updateFormattingConfigPath ( './oxfmt.json' ) ,
135+ ] ) ;
136+
137+ const oxlintConfig = config . toOxlintConfig ( ) ;
138+
139+ strictEqual ( oxlintConfig . run , 'onSave' ) ;
140+ strictEqual ( oxlintConfig . configPath , './somewhere' ) ;
141+ strictEqual ( oxlintConfig . tsConfigPath , './tsconfig.json' ) ;
142+ strictEqual ( oxlintConfig . unusedDisableDirectives , 'deny' ) ;
143+ strictEqual ( oxlintConfig . typeAware , true ) ;
144+ strictEqual ( oxlintConfig . disableNestedConfig , true ) ;
145+ strictEqual ( oxlintConfig . fixKind , 'dangerous_fix' ) ;
146+ } ) ;
147+
148+ test ( 'toOxfmtConfig method' , async ( ) => {
149+ const config = new WorkspaceConfig ( WORKSPACE_FOLDER ) ;
150+
151+ await Promise . all ( [
152+ config . updateFormattingExperimental ( true ) ,
153+ config . updateFormattingConfigPath ( './oxfmt.json' ) ,
154+ ] ) ;
155+
156+ const oxfmtConfig = config . toOxfmtConfig ( ) ;
157+
158+ strictEqual ( oxfmtConfig [ 'fmt.experimental' ] , true ) ;
159+ strictEqual ( oxfmtConfig [ 'fmt.configPath' ] , './oxfmt.json' ) ;
160+ } ) ;
93161} ) ;
0 commit comments