mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-08 13:33:42 +08:00
a82935f326
Integrate onroad views, configurable widgets, local settings, steering-profile contracts, Bluetooth and Android Auto with their device and runtime services. Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Daniel Koepping <elkoled@gmail.com> Co-authored-by: Danny <dannyirwin31@yahoo.com> Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com> Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com> Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com> Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu> Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com> Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Co-authored-by: stef <19478336+stefpi@users.noreply.github.com> Co-authored-by: whoisdomi <dcantu83@gmail.com> Co-authored-by: Intelli <contact@intelli.software> Co-authored-by: pharmacomaniac <blittle65@gmail.com> Co-authored-by: prabhaavp <prabhaav@msu.edu>
32 lines
1.8 KiB
JavaScript
32 lines
1.8 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { test } from 'node:test'
|
|
import { BluetoothDeviceList, hasBluetoothName } from '../web/js/bluetooth-devices.js'
|
|
|
|
test('hide address placeholders in discovery formats, retaining real names with model suffixes', () => {
|
|
for (const name of ['', ' ', 'AA:bb:CC:dd:EE:ff', 'aa-bb-cc-dd-ee-ff', 'AABBCCDDEEFF',
|
|
'aabb.ccdd.eeff', 'AA_BB_CC_DD_EE_FF', 'dev_AA_BB_CC_DD_EE_FF',
|
|
'[AA:BB:CC:DD:EE:FF]', '(AA:BB:CC:DD:EE:FF)', '[dev_AA_BB_CC_DD_EE_FF]', ' AA BB CC DD EE FF ']) {
|
|
assert.equal(hasBluetoothName({name}), false, name)
|
|
}
|
|
for (const name of ['IONIQ 6', 'AndroidAuto-8b83', 'Bose QC35 II', 'Tile A1:B2', 'Headphones AA:BB:CC:DD:EE:FF']) {
|
|
assert.equal(hasBluetoothName({name}), true, name)
|
|
}
|
|
assert.equal(hasBluetoothName({name: null}), false)
|
|
})
|
|
|
|
test('stable rows follow addresses with live rename, flags, disappearance and discovery', () => {
|
|
const list = new BluetoothDeviceList()
|
|
const car = {address:'AA:BB:CC:DD:EE:01', name:' IONIQ 6 ', connected:false}
|
|
const adapter = {address:'AA:BB:CC:DD:EE:02', name:'AndroidAuto-8b83'}
|
|
const unnamed = {address:'AA:BB:CC:DD:EE:03', name:'AA-BB-CC-DD-EE-03'}
|
|
assert.deepEqual(list.update([car, adapter, unnamed]).map(d => d.name), ['IONIQ 6', 'AndroidAuto-8b83'])
|
|
assert.equal(car.name, ' IONIQ 6 ')
|
|
assert.deepEqual(list.update([adapter]).map(d => d.address), [adapter.address])
|
|
const current = list.update([adapter, {...car, name:'My IONIQ', connected:true}, {...unnamed, name:'Controller'}])
|
|
assert.deepEqual(current.map(d => d.name), ['My IONIQ', 'AndroidAuto-8b83', 'Controller'])
|
|
assert.equal(current[0].connected, true)
|
|
assert.deepEqual(list.update([{...car, name:car.address}]), [])
|
|
list.reset()
|
|
assert.deepEqual(list.update([adapter, car]).map(d => d.address), [adapter.address, car.address])
|
|
})
|