import { describe, expect, test } from "bun:test"

import { formatNotificationRelativeTime } from "./dates"

describe("formatNotificationRelativeTime", () => {
	test("returns 'только что' for less than a minute", () => {
		expect(
			formatNotificationRelativeTime("2026-04-05T11:59:31.000Z", {
				now: new Date("2026-04-05T12:00:00.000Z"),
			}),
		).toBe("только что")
	})

	test("returns minutes without suffix", () => {
		expect(
			formatNotificationRelativeTime("2026-04-05T11:48:00.000Z", {
				now: new Date("2026-04-05T12:00:00.000Z"),
			}),
		).toBe("12мин")
	})

	test("returns hours without suffix", () => {
		expect(
			formatNotificationRelativeTime("2026-04-05T08:00:00.000Z", {
				now: new Date("2026-04-05T12:00:00.000Z"),
			}),
		).toBe("4ч")
	})

	test("returns days without suffix", () => {
		expect(
			formatNotificationRelativeTime("2026-04-02T12:00:00.000Z", {
				now: new Date("2026-04-05T12:00:00.000Z"),
			}),
		).toBe("3д")
	})

	test("returns weeks without suffix", () => {
		expect(
			formatNotificationRelativeTime("2026-03-22T12:00:00.000Z", {
				now: new Date("2026-04-05T12:00:00.000Z"),
			}),
		).toBe("2нед")
	})
})
