test-date-conversion.js•1.97 kB
/**
* Test automatic date conversion in search_tasks
* Verifies that ISO date strings get converted to Unix timestamps
*/
import { handleSearchTasks } from './build/tools/task/consolidated-handlers.js';
console.log('=== Testing Automatic Date Conversion ===\n');
// Test 1: ISO date string
console.log('Test 1: ISO date string "2024-10-01"');
console.log('Expected: Should convert to Unix timestamp (milliseconds)');
console.log('Testing conversion logic...\n');
// Simulate the conversion that should happen
const testDate = "2024-10-01";
const expectedTimestamp = new Date(testDate).getTime().toString();
console.log(`Input: ${testDate}`);
console.log(`Expected output: ${expectedTimestamp}`);
console.log(`Expected date: ${new Date(parseInt(expectedTimestamp)).toISOString()}\n`);
// Test 2: Already a timestamp
console.log('Test 2: Already a timestamp (milliseconds)');
const timestampMs = "1696118400000";
console.log(`Input: ${timestampMs}`);
console.log(`Expected: Should pass through as-is: ${timestampMs}\n`);
// Test 3: Timestamp in seconds (should convert to milliseconds)
console.log('Test 3: Timestamp in seconds');
const timestampSec = "1696118400";
const expectedMs = (parseInt(timestampSec) * 1000).toString();
console.log(`Input: ${timestampSec}`);
console.log(`Expected: Should convert to milliseconds: ${expectedMs}\n`);
// Test 4: Human-readable date
console.log('Test 4: Human-readable date "December 25, 2024"');
const humanDate = "December 25, 2024";
const humanTimestamp = new Date(humanDate).getTime().toString();
console.log(`Input: ${humanDate}`);
console.log(`Expected output: ${humanTimestamp}`);
console.log(`Expected date: ${new Date(parseInt(humanTimestamp)).toISOString()}\n`);
console.log('=== Date Conversion Logic Test Complete ===\n');
console.log('Note: The actual API call would use these converted timestamps.');
console.log('The handler should automatically convert date strings before calling the ClickUp API.\n');