"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const busy_scenarios_js_1 = require("./busy-scenarios.js");
(0, vitest_1.describe)('BUSY_SCENARIOS', () => {
    (0, vitest_1.it)('should have at least 4 predefined scenarios', () => {
        (0, vitest_1.expect)(busy_scenarios_js_1.BUSY_SCENARIOS.length).toBeGreaterThanOrEqual(4);
    });
    (0, vitest_1.it)('should have sport scenario with 25-45 min delay', () => {
        const sport = busy_scenarios_js_1.BUSY_SCENARIOS.find((s) => s.id === 'sport');
        (0, vitest_1.expect)(sport).toBeDefined();
        (0, vitest_1.expect)(sport.delayMinutes.min).toBe(25);
        (0, vitest_1.expect)(sport.delayMinutes.max).toBe(45);
    });
    (0, vitest_1.it)('should have shower scenario with 15-30 min delay', () => {
        const shower = busy_scenarios_js_1.BUSY_SCENARIOS.find((s) => s.id === 'shower');
        (0, vitest_1.expect)(shower).toBeDefined();
        (0, vitest_1.expect)(shower.delayMinutes.min).toBe(15);
        (0, vitest_1.expect)(shower.delayMinutes.max).toBe(30);
    });
    (0, vitest_1.it)('should have social scenario with 30-60 min delay', () => {
        const social = busy_scenarios_js_1.BUSY_SCENARIOS.find((s) => s.id === 'social');
        (0, vitest_1.expect)(social).toBeDefined();
        (0, vitest_1.expect)(social.delayMinutes.min).toBe(30);
        (0, vitest_1.expect)(social.delayMinutes.max).toBe(60);
    });
    (0, vitest_1.it)('should have sleep scenario with night time restriction', () => {
        const sleep = busy_scenarios_js_1.BUSY_SCENARIOS.find((s) => s.id === 'sleep');
        (0, vitest_1.expect)(sleep).toBeDefined();
        (0, vitest_1.expect)(sleep.timeRestriction).toBeDefined();
        (0, vitest_1.expect)(sleep.timeRestriction.start).toBe(23);
        (0, vitest_1.expect)(sleep.timeRestriction.end).toBe(7);
    });
    (0, vitest_1.it)('should have Turkish messages for all scenarios', () => {
        for (const scenario of busy_scenarios_js_1.BUSY_SCENARIOS) {
            (0, vitest_1.expect)(scenario.message.length).toBeGreaterThan(0);
            (0, vitest_1.expect)(scenario.name.length).toBeGreaterThan(0);
        }
    });
    (0, vitest_1.it)('each scenario should have unique id', () => {
        const ids = busy_scenarios_js_1.BUSY_SCENARIOS.map((s) => s.id);
        (0, vitest_1.expect)(new Set(ids).size).toBe(ids.length);
    });
});
(0, vitest_1.describe)('selectRandomScenario', () => {
    (0, vitest_1.it)('should return a valid scenario for daytime hours', () => {
        const scenario = (0, busy_scenarios_js_1.selectRandomScenario)(14);
        (0, vitest_1.expect)(scenario).toBeDefined();
        (0, vitest_1.expect)(scenario.id).toBeTruthy();
        (0, vitest_1.expect)(scenario.message).toBeTruthy();
    });
    (0, vitest_1.it)('should not return sleep scenario during daytime', () => {
        // Run multiple times to increase confidence
        for (let i = 0; i < 50; i++) {
            const scenario = (0, busy_scenarios_js_1.selectRandomScenario)(14);
            (0, vitest_1.expect)(scenario.id).not.toBe('sleep');
        }
    });
    (0, vitest_1.it)('should return eligible scenarios during night hours', () => {
        const results = new Set();
        for (let i = 0; i < 100; i++) {
            results.add((0, busy_scenarios_js_1.selectRandomScenario)(2).id);
        }
        // Sleep should appear at night
        (0, vitest_1.expect)(results.has('sleep')).toBe(true);
    });
    (0, vitest_1.it)('should return a scenario for every hour of the day', () => {
        for (let hour = 0; hour < 24; hour++) {
            const scenario = (0, busy_scenarios_js_1.selectRandomScenario)(hour);
            (0, vitest_1.expect)(scenario).toBeDefined();
            (0, vitest_1.expect)(busy_scenarios_js_1.BUSY_SCENARIOS).toContain(scenario);
        }
    });
});
(0, vitest_1.describe)('calculateBusyDelay', () => {
    (0, vitest_1.it)('should return delay in seconds', () => {
        const scenario = {
            id: 'test',
            name: 'Test',
            message: 'test',
            delayMinutes: { min: 10, max: 20 },
        };
        const delay = (0, busy_scenarios_js_1.calculateBusyDelay)(scenario);
        // min * 0.85 * 60 = 510, max * 1.15 * 60 = 1380
        (0, vitest_1.expect)(delay).toBeGreaterThanOrEqual(510);
        (0, vitest_1.expect)(delay).toBeLessThanOrEqual(1380);
    });
    (0, vitest_1.it)('should produce delays within extended range for sport scenario', () => {
        const sport = busy_scenarios_js_1.BUSY_SCENARIOS.find((s) => s.id === 'sport');
        for (let i = 0; i < 50; i++) {
            const delay = (0, busy_scenarios_js_1.calculateBusyDelay)(sport);
            // 25 * 0.85 * 60 = 1275, 45 * 1.15 * 60 = 3105
            (0, vitest_1.expect)(delay).toBeGreaterThanOrEqual(25 * 0.85 * 60);
            (0, vitest_1.expect)(delay).toBeLessThanOrEqual(45 * 1.15 * 60);
        }
    });
    (0, vitest_1.it)('should not always return the same value (has randomness)', () => {
        const scenario = busy_scenarios_js_1.BUSY_SCENARIOS[0];
        const results = new Set();
        for (let i = 0; i < 20; i++) {
            results.add((0, busy_scenarios_js_1.calculateBusyDelay)(scenario));
        }
        (0, vitest_1.expect)(results.size).toBeGreaterThan(1);
    });
    (0, vitest_1.it)('should return an integer (rounded seconds)', () => {
        const scenario = busy_scenarios_js_1.BUSY_SCENARIOS[0];
        for (let i = 0; i < 10; i++) {
            const delay = (0, busy_scenarios_js_1.calculateBusyDelay)(scenario);
            (0, vitest_1.expect)(Number.isInteger(delay)).toBe(true);
        }
    });
});
//# sourceMappingURL=busy-scenarios.test.js.map