Replace didar/live-deal filters with createdAt cutoff and promotedFromPriorAt; add unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
activityPriorWhere,
|
|
dealPriorWhere,
|
|
personPriorWhere,
|
|
} from '../src/common/prior-archive';
|
|
|
|
const cutoff = new Date('2026-10-01T00:00:00.000Z');
|
|
|
|
describe('بایگانی اطلاعات قبل — تاریخ قطع', () => {
|
|
it('بدون لنز یا بدون تاریخ فیلتر نمیگذارد', () => {
|
|
assert.deepEqual(dealPriorWhere('off', cutoff), {});
|
|
assert.deepEqual(dealPriorWhere('current', null), {});
|
|
assert.deepEqual(activityPriorWhere('archive', undefined), {});
|
|
assert.deepEqual(personPriorWhere('current'), {});
|
|
});
|
|
|
|
it('کار جاری: بعد از قطع یا منتقلشده', () => {
|
|
assert.deepEqual(dealPriorWhere('current', cutoff), {
|
|
OR: [
|
|
{ createdAt: { gte: cutoff } },
|
|
{ promotedFromPriorAt: { not: null } },
|
|
],
|
|
});
|
|
});
|
|
|
|
it('بایگانی: قبل از قطع و بدون برچسب انتقال', () => {
|
|
assert.deepEqual(activityPriorWhere('archive', cutoff), {
|
|
createdAt: { lt: cutoff },
|
|
promotedFromPriorAt: null,
|
|
});
|
|
});
|
|
|
|
it('استثنای موعد آینده دیگر نیست', () => {
|
|
const w = JSON.stringify(dealPriorWhere('current', cutoff));
|
|
assert.equal(w.includes('expectedCloseAt'), false);
|
|
assert.equal(w.includes('didar'), false);
|
|
});
|
|
});
|