{% from "_macros.md.j2" import js_import %}
{%- if test_framework == "mocha" -%}
Using **Mocha** with **node:assert/strict**, write a test suite for the following {% if is_async %}**ASYNC** {% endif %}JavaScript function.
{% if is_async %}

**CRITICAL: This function is ASYNCHRONOUS**
- All test functions MUST be async: `it('...', async () => { ... })`
- All calls to {{ function_name }} MUST be awaited: `await {{ function_name }}(...)`
- Test both successful and error cases for async operations
{% endif %}

**Function to Test:**
```javascript
{{ function_code }}
```

**CRITICAL: Use this exact import statement{% if not is_async %} - copy it EXACTLY as shown, do NOT add .js or any file extension{% else %} (do not modify the path){% endif %}:**
```javascript
{{ js_import(import_style, import_name, module_path, module_system) }}
```

**Assertion API — use ONLY these methods:**
{%- if is_async %}
- `assert.strictEqual(actual, expected)` — for primitive equality
- `assert.deepStrictEqual(actual, expected)` — for object/array equality
- `await assert.rejects(async () => { ... })` — for async error testing
- `assert.ok(value)` — for truthy checks
{%- else %}
- `assert.strictEqual(actual, expected)` — for primitive equality
- `assert.deepStrictEqual(actual, expected)` — for object/array equality
- `assert.throws(() => { ... })` — for error testing
- `assert.ok(value)` — for truthy checks
{%- endif %}

**Template — follow this structure exactly:**
```javascript
const assert = require('node:assert/strict');
{{ js_import(import_style, import_name, module_path, module_system) }}

describe('{{ function_name }}', () => {
{% if is_async %}
    // Basic Test Cases
    describe('Basic async functionality', () => {
        it('should resolve with correct value', async () => {
            const result = await {{ function_name }}(/* args */);
            assert.strictEqual(result, /* expected */);
        });
    });

    // Edge Test Cases
    describe('Async edge cases', () => {
        it('should handle async error case', async () => {
            await assert.rejects(
                async () => { await {{ function_name }}(/* invalid args */); },
                { name: 'Error' }
            );
        });
    });

    // Large Scale Test Cases
    describe('Large scale tests', () => {
        it('should handle large inputs correctly', async () => {
            const result = await {{ function_name }}(/* large input */);
            assert.strictEqual(result, /* expected */);
        });
    });
{% else %}
    // Basic Test Cases
    describe('Basic functionality', () => {
        it('should handle normal input', () => {
            assert.strictEqual({{ function_name }}(/* args */), /* expected */);
        });
    });

    // Edge Test Cases
    describe('Edge cases', () => {
        it('should handle edge case', () => {
            assert.strictEqual({{ function_name }}(/* args */), /* expected */);
        });
    });

    // Large Scale Test Cases
    describe('Performance tests', () => {
        it('should handle large inputs efficiently', () => {
            assert.ok({{ function_name }}(/* large args */) !== undefined);
        });
    });
{% endif %}
});
```
{%- else -%}
Using the **{{ test_framework }}** testing framework, write a test suite for the following {% if is_async %}**ASYNC** {% endif %}JavaScript function.

**IMPORTANT**: You MUST use {{ test_framework }} syntax. If {{ test_framework }} is "vitest", use `vi.mock()` and `vi.fn()`. If {{ test_framework }} is "jest", use `jest.mock()` and `jest.fn()`. Do NOT mix frameworks.
{% if is_async %}

**CRITICAL: This function is ASYNCHRONOUS**
- All test functions MUST be async: `test('...', async () => { ... })`
- All calls to {{ function_name }} MUST be awaited: `await {{ function_name }}(...)`
- Test both successful and error cases for async operations
{% endif %}

**Function to Test:**
```javascript
{{ function_code }}
```

**CRITICAL: Use this exact import statement{% if not is_async %} - copy it EXACTLY as shown, do NOT add .js or any file extension{% else %} (do not modify the path){% endif %}:**
```javascript
{{ js_import(import_style, import_name, module_path, module_system) }}
```

**CRITICAL: VITEST IMPORTS REQUIRED**
If test_framework is "vitest", you MUST import test functions from 'vitest' since globals are NOT enabled:
```javascript
import { describe, test, expect, vi, beforeEach, afterEach } from 'vitest';
```
For "jest", globals are typically enabled so no import is needed.

**Template to Follow:**
```javascript
// vitest imports (REQUIRED for vitest - globals are NOT enabled by default)
import { describe, test, expect, vi, beforeEach, afterEach } from 'vitest';
// function import
{{ js_import(import_style, import_name, module_path, module_system) }}

// unit tests
describe('{{ function_name }}', () => {
{% if is_async %}
    // Basic Test Cases
    describe('Basic async functionality', () => {
        test('should resolve with correct value', async () => {
            const result = await {{ function_name }}(/* args */);
            expect(result).toBe(/* expected */);
        });
    });

    // Edge Test Cases
    describe('Async edge cases', () => {
        test('should handle async error case', async () => {
            await expect({{ function_name }}(/* invalid args */)).rejects.toThrow();
        });
    });

    // Large Scale Test Cases
    describe('Large scale tests', () => {
        test('should handle large inputs correctly', async () => {
            const result = await {{ function_name }}(/* large input */);
            expect(result).toEqual(/* expected */);
        });
    });
{% else %}
    // Basic Test Cases
    describe('Basic functionality', () => {
        test('should handle normal input', () => {
            // Test implementation
        });
    });

    // Edge Test Cases
    describe('Edge cases', () => {
        test('should handle edge case', () => {
            // Test implementation
        });
    });

    // Large Scale Test Cases
    describe('Performance tests', () => {
        test('should handle large inputs efficiently', () => {
            // Test implementation
        });
    });
{% endif %}
});
```
{%- endif %}

{{ package_comment }}

Reply only with code, in a single markdown code block.
