chore: added first batch of ipc handler tests
This commit is contained in:
1085
tests/ipc/handlers.test.ts
Normal file
1085
tests/ipc/handlers.test.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
import type { PostData } from '../../src/main/engine/PostEngine';
|
import type { PostData } from '../../src/main/engine/PostEngine';
|
||||||
import type { MediaData } from '../../src/main/engine/MediaEngine';
|
import type { MediaData } from '../../src/main/engine/MediaEngine';
|
||||||
|
import type { ProjectData } from '../../src/main/engine/ProjectEngine';
|
||||||
import type { Task, TaskProgress } from '../../src/main/engine/TaskManager';
|
import type { Task, TaskProgress } from '../../src/main/engine/TaskManager';
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
@@ -83,6 +84,36 @@ export function createMockPdfMedia(overrides?: Partial<MediaData>): MediaData {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Project Mock Factory
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
let projectIdCounter = 1;
|
||||||
|
|
||||||
|
export function createMockProject(overrides?: Partial<ProjectData>): ProjectData {
|
||||||
|
const id = overrides?.id ?? `project-${projectIdCounter++}`;
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
name: `Test Project ${id}`,
|
||||||
|
slug: `test-project-${id}`,
|
||||||
|
description: 'A test project',
|
||||||
|
dataPath: undefined,
|
||||||
|
createdAt: now,
|
||||||
|
updatedAt: now,
|
||||||
|
isActive: false,
|
||||||
|
...overrides,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createMockActiveProject(overrides?: Partial<ProjectData>): ProjectData {
|
||||||
|
return createMockProject({
|
||||||
|
isActive: true,
|
||||||
|
...overrides,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
// Task Mock Factory
|
// Task Mock Factory
|
||||||
// ============================================
|
// ============================================
|
||||||
@@ -369,6 +400,7 @@ export function createMockDropboxConflict(overrides?: Partial<DropboxConflict>):
|
|||||||
export function resetMockCounters(): void {
|
export function resetMockCounters(): void {
|
||||||
postIdCounter = 1;
|
postIdCounter = 1;
|
||||||
mediaIdCounter = 1;
|
mediaIdCounter = 1;
|
||||||
|
projectIdCounter = 1;
|
||||||
taskIdCounter = 1;
|
taskIdCounter = 1;
|
||||||
dropboxConflictIdCounter = 1;
|
dropboxConflictIdCounter = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user