@onekeyfe/hd-transport-web-device 1.2.8-alpha.11 → 1.2.8-alpha.110

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.
@@ -196,6 +196,33 @@ describe('ElectronBleTransport protocol detection', () => {
196
196
  });
197
197
  });
198
198
 
199
+ test('passes the advertised color from the native bridge into the descriptor', async () => {
200
+ const nobleBle = createNobleBle();
201
+ nobleBle.enumerate.mockResolvedValueOnce([
202
+ { id: 'colored-pro2-id', name: 'Pro 2 A1B2', bleColorCode: 'B' },
203
+ { id: 'legacy-pro2-id', name: 'Pro 2 C3D4' },
204
+ ] as never);
205
+ const bleTransport = configureTransport(nobleBle);
206
+
207
+ await expect(bleTransport.enumerate()).resolves.toEqual([
208
+ {
209
+ id: 'colored-pro2-id',
210
+ name: 'Pro 2 A1B2',
211
+ path: 'colored-pro2-id',
212
+ debug: false,
213
+ commType: 'electron-ble',
214
+ bleColorCode: 'B',
215
+ },
216
+ {
217
+ id: 'legacy-pro2-id',
218
+ name: 'Pro 2 C3D4',
219
+ path: 'legacy-pro2-id',
220
+ debug: false,
221
+ commType: 'electron-ble',
222
+ },
223
+ ]);
224
+ });
225
+
199
226
  test('does not treat an error envelope from a legacy preload as a successful connect', async () => {
200
227
  const device = { id: 'legacy-error-id', name: 'OneKey Pro 2' };
201
228
  const nobleBle = createNobleBle(device);
@@ -561,9 +588,9 @@ describe('ElectronBleTransport protocol detection', () => {
561
588
 
562
589
  const transport = configureTransport(nobleBle);
563
590
 
564
- await expect(transport.acquire({ uuid: device.id })).rejects.toThrow(
565
- /Unable to detect BLE protocol/
566
- );
591
+ await expect(transport.acquire({ uuid: device.id })).rejects.toMatchObject({
592
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
593
+ });
567
594
  expect(nobleBle.unsubscribe).toHaveBeenCalledWith(device.id);
568
595
  expect(nobleBle.disconnect).toHaveBeenCalledWith(device.id);
569
596
  expect(transport.getProtocolType(device.id)).toBeUndefined();
@@ -629,7 +656,8 @@ describe('ElectronBleTransport protocol detection', () => {
629
656
  await expect(
630
657
  transport.acquire({ uuid: device.id, expectedProtocol: 'V2' })
631
658
  ).rejects.toMatchObject({
632
- errorCode: HardwareErrorCode.RuntimeError,
659
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
660
+ params: { expectedProtocol: 'V2' },
633
661
  });
634
662
 
635
663
  expect(nobleBle.connect).toHaveBeenCalledTimes(1);
@@ -645,12 +673,14 @@ describe('ElectronBleTransport protocol detection', () => {
645
673
  await expect(
646
674
  transport.acquire({ uuid: device.id, expectedProtocol: 'V2' })
647
675
  ).rejects.toMatchObject({
648
- errorCode: HardwareErrorCode.RuntimeError,
676
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
677
+ params: { expectedProtocol: 'V2' },
649
678
  });
650
679
  await expect(
651
680
  transport.acquire({ uuid: device.id, expectedProtocol: 'V2' })
652
681
  ).rejects.toMatchObject({
653
- errorCode: HardwareErrorCode.RuntimeError,
682
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
683
+ params: { expectedProtocol: 'V2' },
654
684
  });
655
685
 
656
686
  expect(transport.getProtocolType(device.id)).toBeUndefined();
@@ -755,7 +785,8 @@ describe('ElectronBleTransport protocol detection', () => {
755
785
  await expect(
756
786
  transport.acquire({ uuid: device.id, expectedProtocol: 'V2' })
757
787
  ).rejects.toMatchObject({
758
- errorCode: HardwareErrorCode.RuntimeError,
788
+ errorCode: HardwareErrorCode.TransportProtocolProbeFailed,
789
+ params: { expectedProtocol: 'V2' },
759
790
  });
760
791
 
761
792
  expect(nobleBle.unsubscribe).toHaveBeenCalledWith(device.id);