inputPredictionSwitch.test.ts 1.3 KB

12345678910111213141516171819202122
  1. // 手机远控输入预测 Host 开关(docs/web-remote-control/mobile-input-prediction.md「开关」)。
  2. import { describe, expect, it } from "vitest";
  3. import {
  4. REMOTE_INPUT_PREDICTION_DEFAULT_ENABLED,
  5. REMOTE_INPUT_PREDICTION_ENV,
  6. isRemoteInputPredictionEnabled,
  7. } from "../src/zcode-agent/inputPredictionSwitch.js";
  8. describe("isRemoteInputPredictionEnabled", () => {
  9. it('缺省开启,"1" 开启,"0" 或其它值关闭', () => {
  10. expect(REMOTE_INPUT_PREDICTION_ENV).toBe("ZCODE_REMOTE_INPUT_PREDICTION");
  11. expect(REMOTE_INPUT_PREDICTION_DEFAULT_ENABLED).toBe(true);
  12. expect(isRemoteInputPredictionEnabled({})).toBe(true);
  13. expect(isRemoteInputPredictionEnabled({ [REMOTE_INPUT_PREDICTION_ENV]: "" })).toBe(true);
  14. expect(isRemoteInputPredictionEnabled({ [REMOTE_INPUT_PREDICTION_ENV]: " " })).toBe(true);
  15. expect(isRemoteInputPredictionEnabled({ [REMOTE_INPUT_PREDICTION_ENV]: "0" })).toBe(false);
  16. expect(isRemoteInputPredictionEnabled({ [REMOTE_INPUT_PREDICTION_ENV]: " 0 " })).toBe(false);
  17. expect(isRemoteInputPredictionEnabled({ [REMOTE_INPUT_PREDICTION_ENV]: "true" })).toBe(false);
  18. expect(isRemoteInputPredictionEnabled({ [REMOTE_INPUT_PREDICTION_ENV]: "1" })).toBe(true);
  19. expect(isRemoteInputPredictionEnabled({ [REMOTE_INPUT_PREDICTION_ENV]: " 1 " })).toBe(true);
  20. });
  21. });