@onekeyfe/hardware-cli 1.2.0-alpha.4 → 1.2.0-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +86 -1
- package/dist/cli.js +364 -273
- package/dist/deviceSelection.d.ts +3 -0
- package/dist/deviceSelection.js +11 -0
- package/dist/deviceStateCommands.d.ts +19 -0
- package/dist/deviceStateCommands.js +62 -0
- package/dist/sdk.d.ts +2 -2
- package/dist/sdk.js +5 -5
- package/dist/session.d.ts +2 -9
- package/dist/session.js +3 -22
- package/dist/transports/nobleBlePlugin.js +113 -70
- package/package.json +7 -6
- package/src/__tests__/cli-version.test.ts +8 -0
- package/src/__tests__/device-selection.test.ts +29 -0
- package/src/__tests__/device-state-commands.test.ts +118 -0
- package/src/__tests__/firmware-update-legacy-command.test.ts +18 -0
- package/src/__tests__/firmware-update-v4-command.test.ts +100 -0
- package/src/__tests__/noble-ble-plugin.test.ts +370 -0
- package/src/__tests__/wallet-session.test.ts +55 -0
- package/src/__tests__/wallpaper-upload-command.test.ts +46 -0
- package/src/cli.ts +459 -321
- package/src/deviceSelection.ts +13 -0
- package/src/deviceStateCommands.ts +71 -0
- package/src/sdk.ts +6 -6
- package/src/session.ts +2 -24
- package/src/transports/nobleBlePlugin.ts +148 -76
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { buildWallpaperUploadMetrics, program } from '../cli';
|
|
2
|
+
|
|
3
|
+
describe('upload-wallpaper CLI command', () => {
|
|
4
|
+
test('exposes a command backed by the SDK wallpaper API', () => {
|
|
5
|
+
const command = program.commands.find(item => item.name() === 'upload-wallpaper');
|
|
6
|
+
|
|
7
|
+
expect(command).toBeDefined();
|
|
8
|
+
expect(command?.description()).toBe('Upload and activate a Pro2 wallpaper');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('reports effective transfer speed from encoded bytes and elapsed time', () => {
|
|
12
|
+
expect(
|
|
13
|
+
buildWallpaperUploadMetrics({
|
|
14
|
+
totalBytes: 2_473_984,
|
|
15
|
+
transferredBytes: 2_473_984,
|
|
16
|
+
startedAt: 1_000,
|
|
17
|
+
endedAt: 2_000,
|
|
18
|
+
lastProgress: 100,
|
|
19
|
+
})
|
|
20
|
+
).toEqual({
|
|
21
|
+
totalBytes: 2_473_984,
|
|
22
|
+
transferredBytes: 2_473_984,
|
|
23
|
+
totalSeconds: 1,
|
|
24
|
+
transferKiBPerSecond: 2416,
|
|
25
|
+
lastProgress: 100,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('uses confirmed bytes for an interrupted transfer rate', () => {
|
|
30
|
+
expect(
|
|
31
|
+
buildWallpaperUploadMetrics({
|
|
32
|
+
totalBytes: 1_855_500,
|
|
33
|
+
transferredBytes: 631_800,
|
|
34
|
+
startedAt: 1_000,
|
|
35
|
+
endedAt: 101_000,
|
|
36
|
+
lastProgress: 34,
|
|
37
|
+
})
|
|
38
|
+
).toEqual({
|
|
39
|
+
totalBytes: 1_855_500,
|
|
40
|
+
transferredBytes: 631_800,
|
|
41
|
+
totalSeconds: 100,
|
|
42
|
+
transferKiBPerSecond: 6.17,
|
|
43
|
+
lastProgress: 34,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|