Skip to content

Add Vitest test suite#3

Merged
byted merged 2 commits intobyted:mainfrom
its-clawdia:add-tests
Mar 5, 2026
Merged

Add Vitest test suite#3
byted merged 2 commits intobyted:mainfrom
its-clawdia:add-tests

Conversation

@its-clawdia
Copy link
Copy Markdown

Adds a test suite using Vitest with 17 tests covering:

  • ConstantsCMD_DISPLAY_ON / CMD_DISPLAY_OFF byte values
  • Constructor — throws when Web Bluetooth is unavailable
  • connect() — correct BT device filter, GATT connection, lastWeightGrams initialization
  • disconnect() — calls gatt.disconnect
  • sendCommand() — writes value to the characteristic
  • subscribe() — starts notifications, parses weight (Int16/10), computes g/s across events, filters unknown events, handles missing handler gracefully
  • unsubscribe() — stops notifications

All Web Bluetooth APIs are mocked; no hardware required.

Run tests with:

npm test

@byted byted merged commit 8c9d04b into byted:main Mar 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants