22 lines
717 B
JavaScript
22 lines
717 B
JavaScript
import assert from 'node:assert/strict';
|
|
import { BUTTONS, setButton, validateFirmwareSize } from '../web/app.js';
|
|
|
|
validateFirmwareSize(16 * 1024 * 1024);
|
|
assert.throws(() => validateFirmwareSize(4 * 1024 * 1024), /exactly 16 MB/);
|
|
|
|
const calls = [];
|
|
const module = {
|
|
_xteink_wasm_set_adc: (...args) => calls.push(['adc', ...args]),
|
|
_xteink_wasm_set_gpio: (...args) => calls.push(['gpio', ...args]),
|
|
};
|
|
setButton(module, 'confirm', true);
|
|
setButton(module, 'confirm', false);
|
|
setButton(module, 'power', true);
|
|
setButton(module, 'power', false);
|
|
assert.deepEqual(calls, [
|
|
['adc', BUTTONS.confirm.channel, BUTTONS.confirm.value],
|
|
['adc', BUTTONS.confirm.channel, 4095],
|
|
['gpio', 3, 0],
|
|
['gpio', 3, 1],
|
|
]);
|