11import { strictEqual } from 'assert' ;
2+ import { workspace } from 'vscode' ;
23import { Config } from './Config.js' ;
34
45suite ( 'Config' , ( ) => {
6+ setup ( async ( ) => {
7+ const wsConfig = workspace . getConfiguration ( 'oxc' ) ;
8+ const keys = [ 'lint.run' , 'enable' , 'trace.server' , 'configPath' , 'path.server' ] ;
9+
10+ await Promise . all ( keys . map ( key => wsConfig . update ( key , undefined ) ) ) ;
11+ } ) ;
12+
513 test ( 'default values on initialization' , ( ) => {
614 const config = new Config ( ) ;
715
@@ -11,4 +19,24 @@ suite('Config', () => {
1119 strictEqual ( config . configPath , '.eslintrc' ) ;
1220 strictEqual ( config . binPath , '' ) ;
1321 } ) ;
22+
23+ test ( 'updating values updates the workspace configuration' , async ( ) => {
24+ const config = new Config ( ) ;
25+
26+ await Promise . all ( [
27+ config . updateRunTrigger ( 'onSave' ) ,
28+ config . updateEnable ( false ) ,
29+ config . updateTrace ( 'messages' ) ,
30+ config . updateConfigPath ( './somewhere' ) ,
31+ config . updateBinPath ( './binary' ) ,
32+ ] ) ;
33+
34+ const wsConfig = workspace . getConfiguration ( 'oxc' ) ;
35+
36+ strictEqual ( wsConfig . get ( 'lint.run' ) , 'onSave' ) ;
37+ strictEqual ( wsConfig . get ( 'enable' ) , false ) ;
38+ strictEqual ( wsConfig . get ( 'trace.server' ) , 'messages' ) ;
39+ strictEqual ( wsConfig . get ( 'configPath' ) , './somewhere' ) ;
40+ strictEqual ( wsConfig . get ( 'path.server' ) , './binary' ) ;
41+ } ) ;
1442} ) ;
0 commit comments