Skip to content

Commit b0477d9

Browse files
authored
Fix extension configuration test (#9715)
1 parent 7b8c4d9 commit b0477d9

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

test/extension.test.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as srcConfiguration from '../src/configuration/configuration';
55
import * as testConfiguration from './testConfiguration';
66

77
import * as packagejson from '../package.json';
8+
import { IConfiguration } from 'src/configuration/iconfiguration';
89

910
suite('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
});

test/testConfiguration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export class Configuration implements IConfiguration {
4242
easymotionDimBackground = true;
4343
easymotionMarkerFontWeight = 'bold';
4444
easymotionKeys = 'hklyuiopnm,qwertzxcvbasdgjf;';
45+
easymotionJumpToAnywhereRegex = '\\b[A-Za-z0-9]|[A-Za-z0-9]\\b|_.|#.|[a-z][A-Z]';
46+
4547
targets: ITargetsConfiguration = {
4648
enable: false,
4749
bracketObjects: {

0 commit comments

Comments
 (0)