ble-pybricks-service: add some tests

This commit is contained in:
David Lechner
2021-03-12 08:54:20 -06:00
parent 4a294f8b25
commit 64c75640ba
3 changed files with 167 additions and 0 deletions
+11
View File
@@ -2,6 +2,7 @@
// Copyright (c) 2020 The Pybricks Authors
import { AsyncSaga } from '../../test';
import { eventProtocolError } from '../ble-pybricks-service/actions';
import { didFailToWrite } from '../ble-uart/actions';
import {
BleDeviceFailToConnectReasonType,
@@ -46,6 +47,16 @@ test('bleDataDidFailToWrite', async () => {
await saga.end();
});
test('eventProtocolError', async () => {
const saga = new AsyncSaga(errorLog);
console.error = jest.fn();
saga.put(eventProtocolError(new Error('test error')));
expect(console.error).toHaveBeenCalledTimes(1);
await saga.end();
});
test('bootloaderDidFailToConnect', async () => {
const saga = new AsyncSaga(errorLog);