mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-11 17:14:15 +00:00
test utils/web-bluetooth
This commit is contained in:
committed by
David Lechner
parent
c979d21255
commit
6ef0dee20c
@@ -0,0 +1,26 @@
|
||||
import { polyfillBluetoothRemoteGATTCharacteristic } from './web-bluetooth';
|
||||
|
||||
describe('polyfillBluetoothRemoteGATTCharacteristic', () => {
|
||||
test('old browser falls back to writeValue', () => {
|
||||
const char = {} as BluetoothRemoteGATTCharacteristic;
|
||||
Object.defineProperty(char, 'writeValue', { value: 'writeValue' });
|
||||
expect(polyfillBluetoothRemoteGATTCharacteristic(char)).toEqual({
|
||||
xWriteValueWithResponse: 'writeValue',
|
||||
xWriteValueWithoutResponse: 'writeValue',
|
||||
});
|
||||
});
|
||||
test('new browser uses writeValueWith(out)Response', () => {
|
||||
const char = {} as BluetoothRemoteGATTCharacteristic;
|
||||
Object.defineProperty(char, 'writeValue', { value: 'writeValue' });
|
||||
Object.defineProperty(char, 'writeValueWithResponse', {
|
||||
value: 'writeValueWithResponse',
|
||||
});
|
||||
Object.defineProperty(char, 'writeValueWithoutResponse', {
|
||||
value: 'writeValueWithoutResponse',
|
||||
});
|
||||
expect(polyfillBluetoothRemoteGATTCharacteristic(char)).toEqual({
|
||||
xWriteValueWithResponse: 'writeValueWithResponse',
|
||||
xWriteValueWithoutResponse: 'writeValueWithoutResponse',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user