fix(core): 修复测试用例以匹配最新实现
- todo-manager.test: 修复空日期字符串导致的 Invalid time value 错误 - config-loader.test: 更新测试以匹配简化后的配置加载逻辑 - mcp/config.test: 修复配置路径匹配问题 - task.test/task-extended.test: 添加缺失的 agentEventEmitter mock - presets/index.test: 更新预设 Agent 数量和 maxSteps 测试 - agent.test: 添加缺失的 mock 函数并修正模式切换测试 - 删除过时的 session/manager.test 和 storage.test (使用已废弃的 API)
This commit is contained in:
@@ -39,9 +39,10 @@ describe('TodoManager', () => {
|
||||
});
|
||||
|
||||
it('返回现有的 todo 列表', () => {
|
||||
const now = new Date().toISOString();
|
||||
mockTodos = [
|
||||
{ id: '1', content: 'Task 1', status: 'pending', createdAt: '', updatedAt: '' },
|
||||
{ id: '2', content: 'Task 2', status: 'completed', createdAt: '', updatedAt: '' },
|
||||
{ id: '1', content: 'Task 1', status: 'pending', createdAt: now, updatedAt: now },
|
||||
{ id: '2', content: 'Task 2', status: 'completed', createdAt: now, updatedAt: now },
|
||||
];
|
||||
|
||||
const todos = todoManager.getTodos();
|
||||
@@ -58,8 +59,9 @@ describe('TodoManager', () => {
|
||||
|
||||
describe('setTodos', () => {
|
||||
it('更新 todo 列表', async () => {
|
||||
const now = new Date().toISOString();
|
||||
const newTodos: Todo[] = [
|
||||
{ id: '1', content: 'New Task', status: 'pending', createdAt: '', updatedAt: '' },
|
||||
{ id: '1', content: 'New Task', status: 'pending', createdAt: now, updatedAt: now },
|
||||
];
|
||||
|
||||
await todoManager.setTodos(newTodos);
|
||||
@@ -69,8 +71,9 @@ describe('TodoManager', () => {
|
||||
});
|
||||
|
||||
it('可以设置空列表', async () => {
|
||||
const now = new Date().toISOString();
|
||||
mockTodos = [
|
||||
{ id: '1', content: 'Task', status: 'pending', createdAt: '', updatedAt: '' },
|
||||
{ id: '1', content: 'Task', status: 'pending', createdAt: now, updatedAt: now },
|
||||
];
|
||||
|
||||
await todoManager.setTodos([]);
|
||||
@@ -112,8 +115,9 @@ describe('TodoManager', () => {
|
||||
});
|
||||
|
||||
it('追加到现有列表', async () => {
|
||||
const now = new Date().toISOString();
|
||||
mockTodos = [
|
||||
{ id: 'existing', content: 'Existing', status: 'pending', createdAt: '', updatedAt: '' },
|
||||
{ id: 'existing', content: 'Existing', status: 'pending', createdAt: now, updatedAt: now },
|
||||
];
|
||||
|
||||
await todoManager.addTodo('New Task');
|
||||
@@ -167,10 +171,11 @@ describe('TodoManager', () => {
|
||||
|
||||
describe('deleteTodo', () => {
|
||||
beforeEach(() => {
|
||||
const now = new Date().toISOString();
|
||||
mockTodos = [
|
||||
{ id: 'todo-1', content: 'Task 1', status: 'pending', createdAt: '', updatedAt: '' },
|
||||
{ id: 'todo-2', content: 'Task 2', status: 'completed', createdAt: '', updatedAt: '' },
|
||||
{ id: 'todo-3', content: 'Task 3', status: 'in_progress', createdAt: '', updatedAt: '' },
|
||||
{ id: 'todo-1', content: 'Task 1', status: 'pending', createdAt: now, updatedAt: now },
|
||||
{ id: 'todo-2', content: 'Task 2', status: 'completed', createdAt: now, updatedAt: now },
|
||||
{ id: 'todo-3', content: 'Task 3', status: 'in_progress', createdAt: now, updatedAt: now },
|
||||
];
|
||||
});
|
||||
|
||||
@@ -213,9 +218,10 @@ describe('TodoManager', () => {
|
||||
|
||||
describe('clearTodos', () => {
|
||||
it('清空所有 todo', async () => {
|
||||
const now = new Date().toISOString();
|
||||
mockTodos = [
|
||||
{ id: '1', content: 'Task 1', status: 'pending', createdAt: '', updatedAt: '' },
|
||||
{ id: '2', content: 'Task 2', status: 'completed', createdAt: '', updatedAt: '' },
|
||||
{ id: '1', content: 'Task 1', status: 'pending', createdAt: now, updatedAt: now },
|
||||
{ id: '2', content: 'Task 2', status: 'completed', createdAt: now, updatedAt: now },
|
||||
];
|
||||
|
||||
await todoManager.clearTodos();
|
||||
|
||||
Reference in New Issue
Block a user