From f3c813646295ea3cd70bb2dae2e2942070e12ce9 Mon Sep 17 00:00:00 2001 From: thegecko Date: Sat, 27 May 2023 21:14:39 +0100 Subject: [PATCH] Add BluetoothUUID tests --- test/bluetooth.test.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test/bluetooth.test.js b/test/bluetooth.test.js index d07e6dc9..523ef4a5 100644 --- a/test/bluetooth.test.js +++ b/test/bluetooth.test.js @@ -1,6 +1,7 @@ const assert = require('assert'); const bluetooth = require('../').bluetooth; const Bluetooth = require('../').Bluetooth; +const BluetoothUUID = require('../').BluetoothUUID; describe('bluetooth module', () => { it('should describe basic constants', () => { @@ -17,7 +18,7 @@ describe('device', () => { }); }); - it('should return a device with requestDevice', async () => { + it('should return a device with requestDevice', () => { assert.notEqual(device, undefined); }); @@ -286,3 +287,25 @@ describe('descriptors', () => { }); */ }); + +describe('bluetoothuuid', () => { + it('should get service', () => { + const uuid = BluetoothUUID.getService('cycling_power'); + assert.equal(uuid, '00001818-0000-1000-8000-00805f9b34fb'); + }); + + it('should get characteristic', () => { + const uuid = BluetoothUUID.getCharacteristic('ieee_11073-20601_regulatory_certification_data_list'); + assert.equal(uuid, '00002a2a-0000-1000-8000-00805f9b34fb'); + }); + + it('should get descriptor', () => { + const uuid = BluetoothUUID.getDescriptor('gatt.characteristic_presentation_format'); + assert.equal(uuid, '00002904-0000-1000-8000-00805f9b34fb'); + }); + + it('should get canonical uuid', () => { + const uuid = BluetoothUUID.canonicalUUID(0x2A2B); + assert.equal(uuid, '00002a2b-0000-1000-8000-00805f9b34fb'); + }); +});