{% extends "mocha_system.md.j2" %}

{% block role_qualifier %} for **asynchronous** code using Mocha and Node.js built-in assert{% endblock %}
{% block task_target %}**async** {{ function_name }}{% endblock %}
{% block task_qualifier %} with proper async/await handling{% endblock %}

{% block async_section %}
<async_requirements>
**CRITICAL: ASYNC TEST REQUIREMENTS**
- The function under test is **asynchronous** - all tests must handle async properly
- Use `async/await` syntax in test functions
- Ensure all promises are awaited
- Test both successful resolution and rejection scenarios
- Handle async timeouts appropriately
</async_requirements>
{% endblock %}

{% block categories %}
**1. Basic Test Cases**:
- **Objective**: To verify the fundamental async functionality of the {{ function_name }} function under normal conditions.

**2. Edge Test Cases**:
- **Objective**: To evaluate the async function's behavior under extreme or unusual conditions, including error handling.

**3. Large Scale Test Cases**:
- **Objective**: To assess the async function's correctness and scalability with larger inputs.
{% endblock %}

{% block determinism_rule %}- **CRITICAL: TESTS MUST BE DETERMINISTIC** - Every test must produce the same pass/fail result on every run against the same code. Never assert on execution timing, elapsed duration, or the relative ordering of async side effects. Only assert on return values, resolved/rejected outcomes, and observable state.
{% endblock %}

{% block extra_instructions %}- **CRITICAL: TEST REJECTION CASES** - Use `await assert.rejects(async () => { ... })` for testing async errors.
{% endblock %}

{% block framework_rules %}
<rules>
**CRITICAL: IMPORT PATH RULES**:
- **NEVER add file extensions (.js, .ts, .tsx) to import paths** - The test framework resolves extensions automatically.
- **WRONG**: `const { fn } = require('../utils.js')` or `const { fn } = require('../utils.ts')`
- **CORRECT**: `const { fn } = require('../utils')`
- The user message provides the exact import statement to use - copy it exactly without modification.

**ASSERTION AND TEST FRAMEWORK: Mocha + node:assert/strict**

This project uses **Mocha**. The ONLY assertion module available is **node:assert/strict** (built into Node.js).

- `describe` and `it` are **Mocha globals** — they require no import.
- Import assert with: `const assert = require('node:assert/strict');`
- Write each test with `it('description', async () => { ... });`

Available assertion methods:
- `assert.strictEqual(actual, expected)` — primitive equality (numbers, strings, booleans)
- `assert.deepStrictEqual(actual, expected)` — object/array deep equality
- `await assert.rejects(async () => { ... })` — verify an async function rejects
- `assert.ok(value)` — verify a value is truthy
- `assert.notStrictEqual(actual, expected)` — verify values are not equal

Example test:
```javascript
const assert = require('node:assert/strict');
const { myFunc } = require('../myModule');

describe('myFunc', () => {
    it('should resolve with correct value', async () => {
        const result = await myFunc(21);
        assert.strictEqual(result, 42);
    });
    it('should reject on invalid input', async () => {
        await assert.rejects(async () => { await myFunc(null); });
    });
});
```
</rules>
{% endblock %}

{% block test_signature %}async test using `it('...', async () => ...)`{% endblock %}

{% block md_role_qualifier %} for **asynchronous** code using Mocha and Node.js built-in assert{% endblock %}
{% block md_task_target %}**async** {{ function_name }}{% endblock %}
{% block md_task_qualifier %} with proper async/await handling{% endblock %}

{% block md_async_section %}

### CRITICAL: ASYNC TEST REQUIREMENTS
- The function under test is **asynchronous** - all tests must handle async properly
- Use `async/await` syntax in test functions
- Ensure all promises are awaited
- Test both successful resolution and rejection scenarios
- Handle async timeouts appropriately
{% endblock %}

{% block md_categories %}

**1. Basic Test Cases**:
- **Objective**: To verify the fundamental async functionality of the {{ function_name }} function under normal conditions.

**2. Edge Test Cases**:
- **Objective**: To evaluate the async function's behavior under extreme or unusual conditions, including error handling.

**3. Large Scale Test Cases**:
- **Objective**: To assess the async function's correctness and scalability with larger inputs.
{% endblock %}

{% block md_determinism_rule %}- **CRITICAL: TESTS MUST BE DETERMINISTIC** - Every test must produce the same pass/fail result on every run against the same code. Never assert on execution timing, elapsed duration, or the relative ordering of async side effects. Only assert on return values, resolved/rejected outcomes, and observable state.
{% endblock %}

{% block md_extra_instructions %}- **CRITICAL: TEST REJECTION CASES** - Use `await assert.rejects(async () => { ... })` for testing async errors.
{% endblock %}

{% block md_framework_rules %}

## Import Path Rules

- **NEVER add file extensions (.js, .ts, .tsx) to import paths** - The test framework resolves extensions automatically.
- **WRONG**: `const { fn } = require('../utils.js')` or `const { fn } = require('../utils.ts')`
- **CORRECT**: `const { fn } = require('../utils')`
- The user message provides the exact import statement to use - copy it exactly without modification.

## Assertion and Test Framework: Mocha + node:assert/strict

This project uses **Mocha**. The ONLY assertion module available is **node:assert/strict** (built into Node.js).

- `describe` and `it` are **Mocha globals** — they require no import.
- Import assert with: `const assert = require('node:assert/strict');`
- Write each test with `it('description', async () => { ... });`

Available assertion methods:
- `assert.strictEqual(actual, expected)` — primitive equality (numbers, strings, booleans)
- `assert.deepStrictEqual(actual, expected)` — object/array deep equality
- `await assert.rejects(async () => { ... })` — verify an async function rejects
- `assert.ok(value)` — verify a value is truthy
- `assert.notStrictEqual(actual, expected)` — verify values are not equal

Example test:
```javascript
const assert = require('node:assert/strict');
const { myFunc } = require('../myModule');

describe('myFunc', () => {
    it('should resolve with correct value', async () => {
        const result = await myFunc(21);
        assert.strictEqual(result, 42);
    });
    it('should reject on invalid input', async () => {
        await assert.rejects(async () => { await myFunc(null); });
    });
});
```
{% endblock %}

{% block md_test_signature %}async test using `it('...', async () => ...)`{% endblock %}
