Files
agent/packages/uhk-common/src/config-serializer/config-items/key-action/none-action.spec.ts
T
Róbert Kiss 35c0d98cd2 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
2017-10-06 22:24:33 +02:00

74 lines
2.3 KiB
TypeScript

import { NoneAction } from './none-action';
import { keyActionType } from './key-action';
import { UhkBuffer } from '../../uhk-buffer';
import { binaryDefaultHelper, jsonDefaultHelper } from '../../../../test/serializer-test-helper';
// TODO: Add null, undefined, empty object, empty buffer test cases
describe('node-action', () => {
it('should be instantiate', () => {
const action = new NoneAction();
expect(action).toBeTruthy();
});
describe('fromJsonObject', () => {
it('should map null', () => {
const action = new NoneAction();
expect(action.fromJsonObject({keyActionType: keyActionType.NoneAction})).toEqual(new NoneAction());
});
});
describe('toJsonObject', () => {
it('should work', () => {
const action = new NoneAction();
expect(action.toJsonObject()).toEqual({
keyActionType: keyActionType.NoneAction
});
});
});
describe('fromBinary', () => {
it('should work', () => {
const buffer = new UhkBuffer();
const action = new NoneAction();
action.toBinary(buffer);
expect(action).toEqual(new NoneAction());
});
});
describe('toBinary', () => {
it('should work', () => {
const buffer = new UhkBuffer();
const action = new NoneAction();
action.toBinary(buffer);
const expected = new UhkBuffer();
expected.offset = 1;
expect(buffer).toEqual(expected);
});
});
describe('toString', () => {
it('should return with "<NoneAction>"', () => {
const action = new NoneAction();
expect(action.toString()).toEqual('<NoneAction>');
});
});
describe('getName', () => {
it('should return with "NoneAction"', () => {
const action = new NoneAction();
expect(action.getName()).toEqual('NoneAction');
});
});
describe('full serialization', () => {
it('should json match with default constructor', () => {
jsonDefaultHelper(new NoneAction());
});
it('should binary match with default constructor', () => {
binaryDefaultHelper(new NoneAction());
});
});
});