test(user-config): fix unit tests (#506)
This commit is contained in:
committed by
László Monda
parent
777832068d
commit
75ab0e2977
+68
-20
@@ -3,8 +3,24 @@ import { UserConfiguration } from '../user-configuration';
|
|||||||
describe('keymap', () => {
|
describe('keymap', () => {
|
||||||
it('should normalize SwitchLayerAction if non base layer action is not SwitchLayerAction', () => {
|
it('should normalize SwitchLayerAction if non base layer action is not SwitchLayerAction', () => {
|
||||||
const inputJsonConfig = {
|
const inputJsonConfig = {
|
||||||
dataModelVersion: 1,
|
dataModelMajorVersion: 3,
|
||||||
|
dataModelMinorVersion: 0,
|
||||||
|
dataModelPatchVersion: 0,
|
||||||
deviceName: 'My UHK',
|
deviceName: 'My UHK',
|
||||||
|
doubleTapSwitchLayerTimeout: 250,
|
||||||
|
iconsAndLayerTextsBrightness: 255,
|
||||||
|
alphanumericSegmentsBrightness: 255,
|
||||||
|
keyBacklightBrightness: 255,
|
||||||
|
mouseMoveInitialSpeed: 5,
|
||||||
|
mouseMoveAcceleration: 35,
|
||||||
|
mouseMoveDeceleratedSpeed: 10,
|
||||||
|
mouseMoveBaseSpeed: 40,
|
||||||
|
mouseMoveAcceleratedSpeed: 80,
|
||||||
|
mouseScrollInitialSpeed: 20,
|
||||||
|
mouseScrollAcceleration: 20,
|
||||||
|
mouseScrollDeceleratedSpeed: 20,
|
||||||
|
mouseScrollBaseSpeed: 20,
|
||||||
|
mouseScrollAcceleratedSpeed: 50,
|
||||||
moduleConfigurations: [],
|
moduleConfigurations: [],
|
||||||
macros: [],
|
macros: [],
|
||||||
keymaps: [
|
keymaps: [
|
||||||
@@ -17,7 +33,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'switchLayer',
|
keyActionType: 'switchLayer',
|
||||||
@@ -30,7 +45,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'keystroke',
|
keyActionType: 'keystroke',
|
||||||
@@ -43,7 +57,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
@@ -52,7 +65,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
@@ -63,8 +75,24 @@ describe('keymap', () => {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
const expectedJsonConfig = {
|
const expectedJsonConfig = {
|
||||||
dataModelVersion: 1,
|
dataModelMajorVersion: 3,
|
||||||
|
dataModelMinorVersion: 0,
|
||||||
|
dataModelPatchVersion: 0,
|
||||||
deviceName: 'My UHK',
|
deviceName: 'My UHK',
|
||||||
|
doubleTapSwitchLayerTimeout: 250,
|
||||||
|
iconsAndLayerTextsBrightness: 255,
|
||||||
|
alphanumericSegmentsBrightness: 255,
|
||||||
|
keyBacklightBrightness: 255,
|
||||||
|
mouseMoveInitialSpeed: 5,
|
||||||
|
mouseMoveAcceleration: 35,
|
||||||
|
mouseMoveDeceleratedSpeed: 10,
|
||||||
|
mouseMoveBaseSpeed: 40,
|
||||||
|
mouseMoveAcceleratedSpeed: 80,
|
||||||
|
mouseScrollInitialSpeed: 20,
|
||||||
|
mouseScrollAcceleration: 20,
|
||||||
|
mouseScrollDeceleratedSpeed: 20,
|
||||||
|
mouseScrollBaseSpeed: 20,
|
||||||
|
mouseScrollAcceleratedSpeed: 50,
|
||||||
moduleConfigurations: [],
|
moduleConfigurations: [],
|
||||||
macros: [],
|
macros: [],
|
||||||
keymaps: [
|
keymaps: [
|
||||||
@@ -77,7 +105,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'switchLayer',
|
keyActionType: 'switchLayer',
|
||||||
@@ -90,7 +117,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'switchLayer',
|
keyActionType: 'switchLayer',
|
||||||
@@ -103,7 +129,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
@@ -112,7 +137,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
@@ -132,8 +156,24 @@ describe('keymap', () => {
|
|||||||
|
|
||||||
it('should normalize SwitchLayerAction if non base layer action is other SwitchLayerAction', () => {
|
it('should normalize SwitchLayerAction if non base layer action is other SwitchLayerAction', () => {
|
||||||
const inputJsonConfig = {
|
const inputJsonConfig = {
|
||||||
dataModelVersion: 1,
|
dataModelMajorVersion: 3,
|
||||||
|
dataModelMinorVersion: 0,
|
||||||
|
dataModelPatchVersion: 0,
|
||||||
deviceName: 'My UHK',
|
deviceName: 'My UHK',
|
||||||
|
doubleTapSwitchLayerTimeout: 250,
|
||||||
|
iconsAndLayerTextsBrightness: 255,
|
||||||
|
alphanumericSegmentsBrightness: 255,
|
||||||
|
keyBacklightBrightness: 255,
|
||||||
|
mouseMoveInitialSpeed: 5,
|
||||||
|
mouseMoveAcceleration: 35,
|
||||||
|
mouseMoveDeceleratedSpeed: 10,
|
||||||
|
mouseMoveBaseSpeed: 40,
|
||||||
|
mouseMoveAcceleratedSpeed: 80,
|
||||||
|
mouseScrollInitialSpeed: 20,
|
||||||
|
mouseScrollAcceleration: 20,
|
||||||
|
mouseScrollDeceleratedSpeed: 20,
|
||||||
|
mouseScrollBaseSpeed: 20,
|
||||||
|
mouseScrollAcceleratedSpeed: 50,
|
||||||
moduleConfigurations: [],
|
moduleConfigurations: [],
|
||||||
macros: [],
|
macros: [],
|
||||||
keymaps: [
|
keymaps: [
|
||||||
@@ -146,7 +186,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'switchLayer',
|
keyActionType: 'switchLayer',
|
||||||
@@ -159,7 +198,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'switchLayer',
|
keyActionType: 'switchLayer',
|
||||||
@@ -172,7 +210,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
@@ -181,7 +218,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
@@ -192,8 +228,24 @@ describe('keymap', () => {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
const expectedJsonConfig = {
|
const expectedJsonConfig = {
|
||||||
dataModelVersion: 1,
|
dataModelMajorVersion: 3,
|
||||||
|
dataModelMinorVersion: 0,
|
||||||
|
dataModelPatchVersion: 0,
|
||||||
deviceName: 'My UHK',
|
deviceName: 'My UHK',
|
||||||
|
doubleTapSwitchLayerTimeout: 250,
|
||||||
|
iconsAndLayerTextsBrightness: 255,
|
||||||
|
alphanumericSegmentsBrightness: 255,
|
||||||
|
keyBacklightBrightness: 255,
|
||||||
|
mouseMoveInitialSpeed: 5,
|
||||||
|
mouseMoveAcceleration: 35,
|
||||||
|
mouseMoveDeceleratedSpeed: 10,
|
||||||
|
mouseMoveBaseSpeed: 40,
|
||||||
|
mouseMoveAcceleratedSpeed: 80,
|
||||||
|
mouseScrollInitialSpeed: 20,
|
||||||
|
mouseScrollAcceleration: 20,
|
||||||
|
mouseScrollDeceleratedSpeed: 20,
|
||||||
|
mouseScrollBaseSpeed: 20,
|
||||||
|
mouseScrollAcceleratedSpeed: 50,
|
||||||
moduleConfigurations: [],
|
moduleConfigurations: [],
|
||||||
macros: [],
|
macros: [],
|
||||||
keymaps: [
|
keymaps: [
|
||||||
@@ -206,7 +258,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'switchLayer',
|
keyActionType: 'switchLayer',
|
||||||
@@ -219,7 +270,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'switchLayer',
|
keyActionType: 'switchLayer',
|
||||||
@@ -232,7 +282,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
@@ -241,7 +290,6 @@ describe('keymap', () => {
|
|||||||
{
|
{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -8,8 +8,24 @@ describe('user-configuration', () => {
|
|||||||
|
|
||||||
it('should transform an empty config', () => {
|
it('should transform an empty config', () => {
|
||||||
jsonTester({
|
jsonTester({
|
||||||
dataModelVersion: 1,
|
dataModelMajorVersion: 3,
|
||||||
|
dataModelMinorVersion: 0,
|
||||||
|
dataModelPatchVersion: 0,
|
||||||
deviceName: 'My UHK',
|
deviceName: 'My UHK',
|
||||||
|
doubleTapSwitchLayerTimeout: 250,
|
||||||
|
iconsAndLayerTextsBrightness: 255,
|
||||||
|
alphanumericSegmentsBrightness: 255,
|
||||||
|
keyBacklightBrightness: 255,
|
||||||
|
mouseMoveInitialSpeed: 5,
|
||||||
|
mouseMoveAcceleration: 35,
|
||||||
|
mouseMoveDeceleratedSpeed: 10,
|
||||||
|
mouseMoveBaseSpeed: 40,
|
||||||
|
mouseMoveAcceleratedSpeed: 80,
|
||||||
|
mouseScrollInitialSpeed: 20,
|
||||||
|
mouseScrollAcceleration: 20,
|
||||||
|
mouseScrollDeceleratedSpeed: 20,
|
||||||
|
mouseScrollBaseSpeed: 20,
|
||||||
|
mouseScrollAcceleratedSpeed: 50,
|
||||||
moduleConfigurations: [],
|
moduleConfigurations: [],
|
||||||
macros: [],
|
macros: [],
|
||||||
keymaps: []
|
keymaps: []
|
||||||
@@ -18,8 +34,24 @@ describe('user-configuration', () => {
|
|||||||
|
|
||||||
it('should transform a null keyActionType ', () => {
|
it('should transform a null keyActionType ', () => {
|
||||||
jsonTester({
|
jsonTester({
|
||||||
dataModelVersion: 1,
|
dataModelMajorVersion: 3,
|
||||||
|
dataModelMinorVersion: 0,
|
||||||
|
dataModelPatchVersion: 0,
|
||||||
deviceName: 'My UHK',
|
deviceName: 'My UHK',
|
||||||
|
doubleTapSwitchLayerTimeout: 250,
|
||||||
|
iconsAndLayerTextsBrightness: 255,
|
||||||
|
alphanumericSegmentsBrightness: 255,
|
||||||
|
keyBacklightBrightness: 255,
|
||||||
|
mouseMoveInitialSpeed: 5,
|
||||||
|
mouseMoveAcceleration: 35,
|
||||||
|
mouseMoveDeceleratedSpeed: 10,
|
||||||
|
mouseMoveBaseSpeed: 40,
|
||||||
|
mouseMoveAcceleratedSpeed: 80,
|
||||||
|
mouseScrollInitialSpeed: 20,
|
||||||
|
mouseScrollAcceleration: 20,
|
||||||
|
mouseScrollDeceleratedSpeed: 20,
|
||||||
|
mouseScrollBaseSpeed: 20,
|
||||||
|
mouseScrollAcceleratedSpeed: 50,
|
||||||
moduleConfigurations: [],
|
moduleConfigurations: [],
|
||||||
macros: [],
|
macros: [],
|
||||||
keymaps: [
|
keymaps: [
|
||||||
@@ -31,7 +63,6 @@ describe('user-configuration', () => {
|
|||||||
layers: [{
|
layers: [{
|
||||||
modules: [{
|
modules: [{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null
|
null
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,15 +1,25 @@
|
|||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
|
|
||||||
const defaultUserConfig = {
|
const defaultUserConfig = {
|
||||||
dataModelVersion: 4,
|
dataModelMajorVersion: 3,
|
||||||
moduleConfigurations: [
|
dataModelMinorVersion: 0,
|
||||||
{
|
dataModelPatchVersion: 0,
|
||||||
id: 1,
|
deviceName: 'My UHK',
|
||||||
initialPointerSpeed: 1,
|
doubleTapSwitchLayerTimeout: 250,
|
||||||
pointerAcceleration: 5,
|
iconsAndLayerTextsBrightness: 255,
|
||||||
maxPointerSpeed: 200
|
alphanumericSegmentsBrightness: 255,
|
||||||
}
|
keyBacklightBrightness: 255,
|
||||||
],
|
mouseMoveInitialSpeed: 5,
|
||||||
|
mouseMoveAcceleration: 35,
|
||||||
|
mouseMoveDeceleratedSpeed: 10,
|
||||||
|
mouseMoveBaseSpeed: 40,
|
||||||
|
mouseMoveAcceleratedSpeed: 80,
|
||||||
|
mouseScrollInitialSpeed: 20,
|
||||||
|
mouseScrollAcceleration: 20,
|
||||||
|
mouseScrollDeceleratedSpeed: 20,
|
||||||
|
mouseScrollBaseSpeed: 20,
|
||||||
|
mouseScrollAcceleratedSpeed: 50,
|
||||||
|
moduleConfigurations: [],
|
||||||
keymaps: [
|
keymaps: [
|
||||||
{
|
{
|
||||||
isDefault: true,
|
isDefault: true,
|
||||||
@@ -21,7 +31,6 @@ const defaultUserConfig = {
|
|||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'keystroke',
|
keyActionType: 'keystroke',
|
||||||
@@ -42,7 +51,6 @@ const defaultUserConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'keystroke',
|
keyActionType: 'keystroke',
|
||||||
@@ -59,7 +67,6 @@ const defaultUserConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
pointerRole: 'scroll',
|
|
||||||
keyActions: []
|
keyActions: []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -68,7 +75,6 @@ const defaultUserConfig = {
|
|||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'none',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'keystroke',
|
keyActionType: 'keystroke',
|
||||||
@@ -89,7 +95,6 @@ const defaultUserConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
pointerRole: 'none',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
{
|
{
|
||||||
keyActionType: 'keystroke',
|
keyActionType: 'keystroke',
|
||||||
@@ -110,7 +115,6 @@ const defaultUserConfig = {
|
|||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -119,7 +123,6 @@ const defaultUserConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
pointerRole: 'scroll',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
@@ -135,7 +138,6 @@ const defaultUserConfig = {
|
|||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -144,7 +146,6 @@ const defaultUserConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
pointerRole: 'move',
|
|
||||||
keyActions: [
|
keyActions: [
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|||||||
Reference in New Issue
Block a user