@@ -5,6 +5,7 @@ import * as srcConfiguration from '../src/configuration/configuration';
55import * as testConfiguration from './testConfiguration' ;
66
77import * as packagejson from '../package.json' ;
8+ import { IConfiguration } from 'src/configuration/iconfiguration' ;
89
910suite ( 'package.json' , ( ) => {
1011 test ( 'all keys have handlers' , async ( ) => {
@@ -27,15 +28,40 @@ suite('package.json', () => {
2728 assert . ok ( pkgConfigurations ) ;
2829 const keys = Object . keys ( pkgConfigurations ) ;
2930 assert . notStrictEqual ( keys . length , 0 ) ;
31+ assert . ok ( keys . every ( ( key ) => key . startsWith ( 'vim.' ) ) ) ;
32+
33+ const isUnhandled = ( configuration : IConfiguration , key : string ) : boolean => {
34+ const keyFirstSegment = key . split ( '.' ) [ 1 ] ; // Extract the first segment without the `vim.` prefix from `key`, e.g. get `foo` from 'vim.foo.bar.baz'.
35+
36+ const handlers = Object . keys ( configuration ) ;
37+ const propertyExists = handlers . includes ( keyFirstSegment ) ;
38+ if ( propertyExists ) {
39+ return false ;
40+ }
41+
42+ // If the property doesn't exist, check the possibility that the field is implemented as a get proxy by calling it.
43+ if ( configuration [ keyFirstSegment ] ) {
44+ return false ;
45+ }
46+
47+ return true ;
48+ } ;
3049
3150 // configuration
32- let handlers = Object . keys ( srcConfiguration . configuration ) ;
33- let unhandled = keys . filter ( ( k ) => handlers . includes ( k ) ) ;
34- assert . strictEqual ( unhandled . length , 0 , 'Missing src handlers for ' + unhandled . join ( ',' ) ) ;
51+ const srcUnhandled = keys . filter ( isUnhandled . bind ( null , srcConfiguration . configuration ) ) ;
52+ assert . strictEqual (
53+ srcUnhandled . length ,
54+ 0 ,
55+ 'Missing src handlers for ' + srcUnhandled . join ( ',' ) ,
56+ ) ;
3557
3658 // test configuration
37- handlers = Object . keys ( new testConfiguration . Configuration ( ) ) ;
38- unhandled = keys . filter ( ( k ) => handlers . includes ( k ) ) ;
39- assert . strictEqual ( unhandled . length , 0 , 'Missing test handlers for ' + unhandled . join ( ',' ) ) ;
59+ const testConfigurationInstance = new testConfiguration . Configuration ( ) ;
60+ const testUnhandled = keys . filter ( isUnhandled . bind ( null , testConfigurationInstance ) ) ;
61+ assert . strictEqual (
62+ testUnhandled . length ,
63+ 0 ,
64+ 'Missing test handlers for ' + testUnhandled . join ( ',' ) ,
65+ ) ;
4066 } ) ;
4167} ) ;
0 commit comments