test(serializer): Add KeystrokeAction tests (#430)
* test: add basis of the unit testing of the uhk-common package * test(serializer): Add KeystrokeAction tests * fix(serializer): Fix KeystrokeAction scancode mapping * test(serializer): Add NoneAction test cases * test(serializer): Add MouseAction test cases * test(serializer): Add PlayMacroAction test cases * test(serializer): Add SwitchKeymapAction test cases * test(serializer): Add UserConfiguration test cases fix KeyAction mapping * test(serializer): Add SwitchLayerAction test cases
This commit is contained in:
committed by
László Monda
parent
85bc5b94e1
commit
35c0d98cd2
19
packages/uhk-common/test/serializer-test-helper.ts
Normal file
19
packages/uhk-common/test/serializer-test-helper.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { UhkBuffer } from '../src/config-serializer';
|
||||
|
||||
export function jsonDefaultHelper(baseObject: any, serializationParam?: any, deserializationParam?: any): void {
|
||||
const json = baseObject.toJsonObject(serializationParam);
|
||||
const newObject = new baseObject.constructor;
|
||||
newObject.fromJsonObject(json, deserializationParam);
|
||||
|
||||
expect(newObject).toEqual(baseObject);
|
||||
}
|
||||
|
||||
export function binaryDefaultHelper(baseObject: any, serializerParam?: any, deserializationParam?: any): void {
|
||||
const buffer = new UhkBuffer();
|
||||
baseObject.toBinary(buffer, serializerParam);
|
||||
buffer.offset = 0;
|
||||
const newObject = new baseObject.constructor;
|
||||
newObject.fromBinary(buffer, deserializationParam);
|
||||
|
||||
expect(newObject).toEqual(baseObject);
|
||||
}
|
||||
Reference in New Issue
Block a user