Source

utils/__tests__/mocks/investigation.mocks.js

import { InvestigationSortBy, InvestigationStatus, SortOrder } from "@typez/investigation/enums";
/**
 * Creates a mock investigation list item with default or overridden values
 * @param {Partial<IInvestigationListItemDto>} overrides - Properties to override defaults
 * @returns {IInvestigationListItemDto} Mock investigation item
 */
export function createMockInvestigationItem(overrides = {}) {
    const defaults = {
        id: "1",
        status: InvestigationStatus.DRAFT_INCOMPLETE,
        title: "Test Investigation",
        grade: "8",
        curriculum: "OpenSciEd",
        views: 100,
        completions: 50,
        urls: 5,
        author: { id: "author1", name: "John Doe", email: null, avatar: null },
        editors: [],
        subject: "Physics",
        unit: "8.1: Forces",
        lesson: "Lesson 1",
        day: 1,
        createdAt: new Date("2024-01-01T00:00:00.000Z"),
        updatedAt: new Date("2024-01-15T00:00:00.000Z"),
        publishedAt: null,
        sentToDevelopmentAt: new Date("2024-01-10T00:00:00.000Z"),
        activity: null,
        timeInDevelopment: null,
    };
    return { ...defaults, ...overrides };
}
/**
 * Creates a mock search DTO with default or overridden values
 * @param {Partial<IInvestigationSearchDto>} overrides - Properties to override defaults
 * @returns {IInvestigationSearchDto} Mock search DTO
 */
export function createMockSearchDto(overrides = {}) {
    const defaults = {
        sortBy: InvestigationSortBy.UPDATED_AT,
        sortOrder: SortOrder.DESC,
    };
    return { ...defaults, ...overrides };
}
/**
 * Pre-defined mock investigation items for common test scenarios
 */
export const mockInvestigations = {
    physics: createMockInvestigationItem({
        id: "1",
        status: InvestigationStatus.DRAFT_INCOMPLETE,
        title: "Physics Investigation",
        grade: "8",
        curriculum: "OpenSciEd",
        views: 100,
        completions: 50,
        urls: 5,
        author: { id: "author1", name: "John Doe", email: null, avatar: null },
        subject: "Physics",
        unit: "8.1: Forces",
        lesson: "Lesson 1",
        day: 1,
        createdAt: new Date("2024-01-01T00:00:00.000Z"),
        updatedAt: new Date("2024-01-15T00:00:00.000Z"),
        sentToDevelopmentAt: new Date("2024-01-10T00:00:00.000Z"),
    }),
    chemistry: createMockInvestigationItem({
        id: "2",
        status: InvestigationStatus.PUBLISHED,
        title: "Chemistry Investigation",
        grade: "7",
        curriculum: "OpenSciEd",
        views: 200,
        completions: 100,
        urls: 10,
        author: { id: "author2", name: "Jane Smith", email: null, avatar: null },
        subject: "Chemistry",
        unit: "7.2: Reactions",
        lesson: "Lesson 2",
        day: 2,
        createdAt: new Date("2024-01-02T00:00:00.000Z"),
        updatedAt: new Date("2024-01-20T00:00:00.000Z"),
        publishedAt: new Date("2024-01-25T00:00:00.000Z"),
        sentToDevelopmentAt: new Date("2024-01-05T00:00:00.000Z"),
    }),
    biology: createMockInvestigationItem({
        id: "3",
        status: InvestigationStatus.IN_DEVELOPMENT,
        title: "Biology Investigation",
        grade: "6",
        curriculum: "Generic",
        views: 50,
        completions: 25,
        urls: 3,
        author: { id: "author1", name: "John Doe", email: null, avatar: null },
        subject: "Biology",
        unit: "6.3: Cells",
        lesson: "Lesson 3",
        day: 3,
        createdAt: new Date("2024-01-03T00:00:00.000Z"),
        updatedAt: new Date("2024-01-10T00:00:00.000Z"),
        sentToDevelopmentAt: new Date("2024-01-01T00:00:00.000Z"),
    }),
};