feat: kboot package (#894)
* feat: kboot package * feat: kboot package * fix: wait 1 sec after device is available * test: fix unit test * refactor: clean unused codes * doc: improve readme.md * doc: improve readme.md * test: fix unit test * chore: fix lint settings * style: fix linting issues
This commit is contained in:
committed by
László Monda
parent
bfc08edfce
commit
3964698cf7
10
packages/kboot/test/util/encode-string-to-parameters.spec.ts
Normal file
10
packages/kboot/test/util/encode-string-to-parameters.spec.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { encodeStringToParams } from '../../src/util';
|
||||
|
||||
describe('encodeStringToParams', () => {
|
||||
xit('should convert 8 character to little endian 4 byte array', () => {
|
||||
const result = encodeStringToParams('0403020108070605');
|
||||
|
||||
const expectedResult = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];
|
||||
expect(result).toEqual(expectedResult);
|
||||
});
|
||||
});
|
||||
17
packages/kboot/test/util/response-parser.spec.ts
Normal file
17
packages/kboot/test/util/response-parser.spec.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { getResponseCode, ResponseCodes } from '../../src';
|
||||
|
||||
describe('response-parser', () => {
|
||||
describe('getResponseCode', () => {
|
||||
it('should return with success', () => {
|
||||
const buffer = Buffer.from([0x03, 0x00, 0x08, 0x00, 0xa7, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00]);
|
||||
const responseCode = getResponseCode(buffer);
|
||||
expect(responseCode).toEqual(ResponseCodes.Success);
|
||||
});
|
||||
|
||||
it('should return with UnknownProperty', () => {
|
||||
const buffer = Buffer.from([0x03, 0x00, 0x08, 0x00, 0xa7, 0x00, 0x00, 0x01, 0x3c, 0x28, 0x00, 0x00]);
|
||||
const responseCode = getResponseCode(buffer);
|
||||
expect(responseCode).toEqual(ResponseCodes.UnknownProperty);
|
||||
});
|
||||
});
|
||||
});
|
||||
16
packages/kboot/test/util/usb/encode-command-option.spec.ts
Normal file
16
packages/kboot/test/util/usb/encode-command-option.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { CommandOption, Commands } from '../../../src';
|
||||
import { encodeCommandOption } from '../../../src/util';
|
||||
|
||||
describe('usb encodeCommandOption', () => {
|
||||
it('should convert correctly', () => {
|
||||
const option: CommandOption = {
|
||||
command: Commands.GetProperty,
|
||||
params: [1, 0, 0, 0, 0, 0, 0, 0]
|
||||
};
|
||||
|
||||
const result = encodeCommandOption(option);
|
||||
// tslint:disable-next-line:max-line-length
|
||||
const expected = [1, 0, 0x0c, 0, 0x07, 0x00, 0x00, 0x02, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user