mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
1.5 KiB
1.5 KiB
Using the {test_framework} testing framework, write a test suite for the following ASYNC JavaScript function.
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
Function to Test:
{function_code}
Template to Follow:
// imports
const {{ {function_name} }} = require('{module_path}');
// unit tests
describe('{function_name}', () => {{
// 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('Concurrent execution tests', () => {{
test('should handle multiple concurrent calls', async () => {{
const results = await Promise.all([
{function_name}(/* args1 */),
{function_name}(/* args2 */),
]);
// assertions
}});
}});
}});
{package_comment}
Reply only with code, in a single markdown code block.