forked from Yara724/api
YARA-885
This commit is contained in:
73
src/helpers/expert-portfolio.spec.ts
Normal file
73
src/helpers/expert-portfolio.spec.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { Types } from "mongoose";
|
||||
import {
|
||||
ExpertFileActivityType,
|
||||
} from "src/users/entities/schema/expert-file-activity.schema";
|
||||
import { expertPortfolioFileIdsFromActivityEvents } from "./expert-portfolio";
|
||||
|
||||
describe("expertPortfolioFileIdsFromActivityEvents", () => {
|
||||
const fid = new Types.ObjectId();
|
||||
|
||||
it("includes handled files after HANDLED", () => {
|
||||
const ids = expertPortfolioFileIdsFromActivityEvents([
|
||||
{
|
||||
fileId: fid,
|
||||
eventType: ExpertFileActivityType.CHECKED,
|
||||
occurredAt: new Date("2026-01-01T10:00:00Z"),
|
||||
},
|
||||
{
|
||||
fileId: fid,
|
||||
eventType: ExpertFileActivityType.HANDLED,
|
||||
occurredAt: new Date("2026-01-01T11:00:00Z"),
|
||||
},
|
||||
]);
|
||||
expect(ids.has(String(fid))).toBe(true);
|
||||
});
|
||||
|
||||
it("includes currently checked files", () => {
|
||||
const ids = expertPortfolioFileIdsFromActivityEvents([
|
||||
{
|
||||
fileId: fid,
|
||||
eventType: ExpertFileActivityType.CHECKED,
|
||||
occurredAt: new Date("2026-01-01T10:00:00Z"),
|
||||
},
|
||||
]);
|
||||
expect(ids.has(String(fid))).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps handled files after a later UNCHECKED (e.g. resend unlock)", () => {
|
||||
const ids = expertPortfolioFileIdsFromActivityEvents([
|
||||
{
|
||||
fileId: fid,
|
||||
eventType: ExpertFileActivityType.CHECKED,
|
||||
occurredAt: new Date("2026-01-01T10:00:00Z"),
|
||||
},
|
||||
{
|
||||
fileId: fid,
|
||||
eventType: ExpertFileActivityType.HANDLED,
|
||||
occurredAt: new Date("2026-01-01T10:30:00Z"),
|
||||
},
|
||||
{
|
||||
fileId: fid,
|
||||
eventType: ExpertFileActivityType.UNCHECKED,
|
||||
occurredAt: new Date("2026-01-01T11:00:00Z"),
|
||||
},
|
||||
]);
|
||||
expect(ids.has(String(fid))).toBe(true);
|
||||
});
|
||||
|
||||
it("excludes files after UNCHECKED without HANDLED", () => {
|
||||
const ids = expertPortfolioFileIdsFromActivityEvents([
|
||||
{
|
||||
fileId: fid,
|
||||
eventType: ExpertFileActivityType.CHECKED,
|
||||
occurredAt: new Date("2026-01-01T10:00:00Z"),
|
||||
},
|
||||
{
|
||||
fileId: fid,
|
||||
eventType: ExpertFileActivityType.UNCHECKED,
|
||||
occurredAt: new Date("2026-01-01T10:30:00Z"),
|
||||
},
|
||||
]);
|
||||
expect(ids.has(String(fid))).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user