Files
CRM_Montzar/apps/api/test/attendance-time.test.ts

18 lines
897 B
TypeScript

import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { loggedInAfterCutoff, tehranCutoff } from '../src/attendance/attendance-time';
describe('ساعت خروج تهران', () => {
it('ورود قبل از ۱۸ خروج اجباری می‌خواهد و ورود بعد از آن نه', () => {
const morning = new Date('2026-10-19T05:30:00.000Z'); // ۰۹:۰۰ تهران
const evening = new Date('2026-10-19T15:30:00.000Z'); // ۱۹:۰۰ تهران
const cutoff = tehranCutoff(evening, '18:00');
assert.ok(cutoff);
assert.equal(morning.getTime() < cutoff.getTime(), true);
assert.equal(evening.getTime() >= cutoff.getTime(), true);
assert.equal(loggedInAfterCutoff(morning, '18:00'), false);
assert.equal(loggedInAfterCutoff(evening, '18:00'), true);
assert.equal(loggedInAfterCutoff(evening, null), false);
});
});