TUI is a doomed path. Stick with CLI

This commit is contained in:
2025-08-17 01:04:10 -05:00
parent f38eff12cd
commit 35960388cf
23 changed files with 6616 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
/**
* Basic ScheduleService Tests
* Tests for core functionality
*/
const fs = require("fs");
const ScheduleService = require("../../../src/tui/services/ScheduleService");
describe("ScheduleService Basic Tests", () => {
let scheduleService;
const testSchedulesFile = "test-schedules-basic.json";
beforeEach(() => {
scheduleService = new ScheduleService();
scheduleService.schedulesFile = testSchedulesFile;
scheduleService.lockFile = `${testSchedulesFile}.lock`;
// Clean up any existing test files
try {
fs.unlinkSync(testSchedulesFile);
} catch (error) {
// File doesn't exist, which is fine
}
});
afterEach(() => {
// Remove test files
try {
fs.unlinkSync(testSchedulesFile);
} catch (error) {
// File doesn't exist, which is fine
}
});
test("should validate schedule data", () => {
const validSchedule = {
operationType: "update",
scheduledTime: new Date(Date.now() + 86400000).toISOString(),
recurrence: "once",
description: "Test schedule",
};
expect(() =>
scheduleService.validateScheduleData(validSchedule)
).not.toThrow();
});
test("should reject invalid operation types", () => {
const invalidSchedule = {
operationType: "invalid",
scheduledTime: new Date(Date.now() + 86400000).toISOString(),
recurrence: "once",
};
expect(() =>
scheduleService.validateScheduleData(invalidSchedule)
).toThrow();
});
test("should calculate checksum correctly", () => {
const data = [{ id: "1", name: "test" }];
const checksum1 = scheduleService.calculateChecksum(data);
const checksum2 = scheduleService.calculateChecksum(data);
expect(checksum1).toBe(checksum2);
expect(typeof checksum1).toBe("string");
expect(checksum1.length).toBe(32); // MD5 hash length
});
test("should provide service statistics", () => {
const stats = scheduleService.getServiceStats();
expect(stats).toHaveProperty("schedulesLoaded");
expect(stats).toHaveProperty("schedulesCount");
expect(stats).toHaveProperty("activeSchedules");
expect(stats).toHaveProperty("pendingOperations");
expect(stats).toHaveProperty("memoryUsage");
});
});