Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { isWithinHostReplyWindow, isWithinReviewWindow } from '@/lib/reviewWindow'
|
|
|
|
describe('isWithinReviewWindow', () => {
|
|
it('is open within 1 month of endsAt', () => {
|
|
const endsAt = new Date('2026-06-01T12:00:00.000Z')
|
|
const now = new Date('2026-06-20T12:00:00.000Z')
|
|
|
|
expect(isWithinReviewWindow(endsAt, now)).toBe(true)
|
|
})
|
|
|
|
it('is closed after 1 month', () => {
|
|
const endsAt = new Date('2026-06-01T12:00:00.000Z')
|
|
const now = new Date('2026-07-02T12:00:00.000Z')
|
|
|
|
expect(isWithinReviewWindow(endsAt, now)).toBe(false)
|
|
})
|
|
|
|
it('rejects invalid dates', () => {
|
|
expect(isWithinReviewWindow('not-a-date')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('isWithinHostReplyWindow', () => {
|
|
it('is open within 2 months of endsAt', () => {
|
|
const endsAt = new Date('2026-06-01T12:00:00.000Z')
|
|
const now = new Date('2026-07-15T12:00:00.000Z')
|
|
|
|
expect(isWithinHostReplyWindow(endsAt, now)).toBe(true)
|
|
})
|
|
|
|
it('is closed after 2 months', () => {
|
|
const endsAt = new Date('2026-06-01T12:00:00.000Z')
|
|
const now = new Date('2026-08-02T12:00:00.000Z')
|
|
|
|
expect(isWithinHostReplyWindow(endsAt, now)).toBe(false)
|
|
})
|
|
})
|