commit f6e5c9738bede6d63655663556feeef025100768
parent a1fa7a0c79dc796c49ef8183830320d5d2bda1fb
Author: Sergey Orlov <wladimirych@gmail.com>
Date: Fri, 10 Sep 2021 16:03:10 +0200
tests: add checks for layers hotkeys
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/test/test_layers.js b/test/test_layers.js
@@ -35,6 +35,9 @@ function checkLayer(layerDef, isWrapper, parentLayer) {
assert.oneOf(options.jnx, [true, false], 'jnx');
assert.oneOf(options.noCors, [true, false, undefined], 'noCors');
}
+ if ('hotkey' in options) {
+ assert.match(options.hotkey, /^[A-Z]$/u);
+ }
}
layersDefs.forEach(function (layerDef) {
@@ -104,6 +107,26 @@ test('Layers short names unique', function () {
assert.isEmpty(Array.from(duplicates), 'duplicate short names');
});
+test('Layers hotkeys unique', function () {
+ const seen = new Set();
+ const duplicates = new Set();
+ for (const layerDef of layersDefs) {
+ let hotkey = layerDef.layer.options.hotkey;
+ if (!hotkey) {
+ hotkey = layerDef.layer.options.code;
+ if (hotkey.length !== 1) {
+ continue;
+ }
+ }
+
+ if (seen.has(hotkey)) {
+ duplicates.add(hotkey);
+ }
+ seen.add(hotkey);
+ }
+ assert.isEmpty(Array.from(duplicates), 'duplicate hotkeys');
+});
+
suite('Layers groups definitions');
test('Groups valid', function () {