Skip to content

Commit 0472978

Browse files
committed
ble-pybricks-service/sagas: simplify test
I meant to change this before merging the previous commit, but missed it. The mismatch test was hard to understand and didn't increase coverage, so let's leave it out.
1 parent 14f4716 commit 0472978

File tree

1 file changed

+8
-40
lines changed

1 file changed

+8
-40
lines changed

src/ble-pybricks-service/sagas.test.ts

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -232,49 +232,17 @@ describe('event decoder', () => {
232232
]).buffer,
233233
),
234234
],
235-
[
236-
'write appdata mismatch',
237-
[
238-
0x02, // write AppData event
239-
't'.charCodeAt(0), //payload
240-
'e'.charCodeAt(0),
241-
't'.charCodeAt(0),
242-
't'.charCodeAt(0),
243-
],
244-
didReceiveWriteAppData(
245-
new Uint8Array([
246-
't'.charCodeAt(0),
247-
'e'.charCodeAt(0),
248-
'x'.charCodeAt(0),
249-
't'.charCodeAt(0),
250-
]).buffer,
251-
),
252-
true,
253-
false,
254-
],
255-
])(
256-
'decode %s event',
257-
async (_n, message, expected, isEqual = true, isStrictlyEqual = true) => {
258-
const saga = new AsyncSaga(blePybricksService);
259-
const notification = new Uint8Array(message);
235+
])('decode %s event', async (_n, message, expected) => {
236+
const saga = new AsyncSaga(blePybricksService);
237+
const notification = new Uint8Array(message);
260238

261-
saga.put(didNotifyEvent(new DataView(notification.buffer)));
239+
saga.put(didNotifyEvent(new DataView(notification.buffer)));
262240

263-
const action = await saga.take();
264-
if (isEqual) {
265-
expect(action).toEqual(expected);
266-
} else {
267-
expect(action).not.toEqual(expected);
268-
}
269-
if (isStrictlyEqual) {
270-
expect(action).toStrictEqual(expected);
271-
} else {
272-
expect(action).not.toStrictEqual(expected);
273-
}
241+
const action = await saga.take();
242+
expect(action).toEqual(expected);
274243

275-
await saga.end();
276-
},
277-
);
244+
await saga.end();
245+
});
278246

279247
test.each([
280248
[

0 commit comments

Comments
 (0)