fix(statusline): re-arm polling when config changes (#1416)
Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
DEFAULT_STATUS_LINE_DEBOUNCE_MS,
|
||||
normalizeStatusLineConfig,
|
||||
} from "../../cli/helpers/statusLineConfig";
|
||||
import { buildRefreshIntervalPlan } from "../../cli/hooks/useConfigurableStatusLine";
|
||||
|
||||
describe("statusline controller-related config", () => {
|
||||
test("normalizes debounce and refresh interval defaults", () => {
|
||||
@@ -29,3 +30,43 @@ describe("statusline controller-related config", () => {
|
||||
expect(normalized.debounceMs).toBe(50);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildRefreshIntervalPlan", () => {
|
||||
test("returns no-op when interval is unchanged", () => {
|
||||
expect(buildRefreshIntervalPlan(null, null)).toEqual({
|
||||
shouldClearExistingInterval: false,
|
||||
shouldArmInterval: false,
|
||||
nextRefreshIntervalMs: null,
|
||||
});
|
||||
|
||||
expect(buildRefreshIntervalPlan(5000, 5000)).toEqual({
|
||||
shouldClearExistingInterval: false,
|
||||
shouldArmInterval: false,
|
||||
nextRefreshIntervalMs: 5000,
|
||||
});
|
||||
});
|
||||
|
||||
test("arms interval when moving from off to polling", () => {
|
||||
expect(buildRefreshIntervalPlan(null, 5000)).toEqual({
|
||||
shouldClearExistingInterval: false,
|
||||
shouldArmInterval: true,
|
||||
nextRefreshIntervalMs: 5000,
|
||||
});
|
||||
});
|
||||
|
||||
test("re-arms interval when polling cadence changes", () => {
|
||||
expect(buildRefreshIntervalPlan(5000, 1000)).toEqual({
|
||||
shouldClearExistingInterval: true,
|
||||
shouldArmInterval: true,
|
||||
nextRefreshIntervalMs: 1000,
|
||||
});
|
||||
});
|
||||
|
||||
test("clears interval when polling is disabled", () => {
|
||||
expect(buildRefreshIntervalPlan(5000, null)).toEqual({
|
||||
shouldClearExistingInterval: true,
|
||||
shouldArmInterval: false,
|
||||
nextRefreshIntervalMs: null,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user