Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
Add test coverage to identifyTargetId
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-cortes committed Jun 11, 2021
1 parent 0347b99 commit 9df7a0f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/devices/tests/identifyTargetId.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow
import { identifyTargetId } from "../src/";

test("check that known targetIds match known devices", () => {
const knownTargetIds = {
nanoS: [823132162, 823132163, 823132164],
nanoX: [855638020],
blue: [822149124],
};

for (const modelId in knownTargetIds) {
const ids = knownTargetIds[modelId];
ids.forEach((id) => {
const deviceModel = identifyTargetId(id);
expect(deviceModel?.id).toBe(modelId);
});
}
});

test("check that unknown targetId is undefined", () => {
const shouldBeUndefiend = identifyTargetId(0x123456789);
expect(shouldBeUndefiend?.id).toBeFalsy();
});

0 comments on commit 9df7a0f

Please sign in to comment.