import { describe, it, expect } from 'vitest';
import { easeInOutCubic } from '../hooks/useAnimatedLayout';

describe('animated-layout', () => {
	describe('easeInOutCubic', () => {
		it('returns 0 at t=0', () => {
			expect(easeInOutCubic(0)).toBe(0);
		});

		it('returns 1 at t=1', () => {
			expect(easeInOutCubic(1)).toBe(1);
		});

		it('returns 0.5 at t=0.5', () => {
			expect(easeInOutCubic(0.5)).toBe(0.5);
		});

		it('is less than 0.5 for t<0.5', () => {
			expect(easeInOutCubic(0.25)).toBeLessThan(0.5);
		});

		it('is greater than 0.5 for t>0.5', () => {
			expect(easeInOutCubic(0.75)).toBeGreaterThan(0.5);
		});

		it('is monotonically increasing', () => {
			let prev = 0;
			for (let t = 0; t <= 1; t += 0.1) {
				const val = easeInOutCubic(t);
				expect(val).toBeGreaterThanOrEqual(prev - 0.0001); // float tolerance
				prev = val;
			}
		});

		it('starts slow (first derivative near 0)', () => {
			// At t=0.05, value should be very small
			expect(easeInOutCubic(0.05)).toBeLessThan(0.01);
		});

		it('ends slow (derivative near 0 at t=1)', () => {
			// At t=0.95, value should be very close to 1
			expect(easeInOutCubic(0.95)).toBeGreaterThan(0.99);
		});

		it('output stays in [0,1] range', () => {
			for (let t = 0; t <= 1; t += 0.01) {
				const val = easeInOutCubic(t);
				expect(val).toBeGreaterThanOrEqual(0);
				expect(val).toBeLessThanOrEqual(1);
			}
		});
	});
});
