mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-03-03 02:17:01 +00:00
test: extend fail test with different error messages
This commit is contained in:
@@ -38,6 +38,33 @@ export async function runConvertFailTest(convertFn: ConvertFnWithExecFile) {
|
||||
expect(
|
||||
convertFn("input.obj", "obj", "stl", "output.stl", undefined, mockExecFile),
|
||||
).rejects.toMatch(/error: Error: Test error/);
|
||||
|
||||
// Test with error object lacking 'message' property
|
||||
const mockExecFileNoMessage: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
// Simulate a non-standard error object
|
||||
callback({ notMessage: true } as unknown as ExecFileException, "", "");
|
||||
};
|
||||
|
||||
expect(
|
||||
convertFn("input.obj", "obj", "stl", "output.stl", undefined, mockExecFileNoMessage),
|
||||
).rejects.toMatch(/error:/i);
|
||||
|
||||
// Test with a non-object error (e.g., a string)
|
||||
const mockExecFileStringError: ExecFileFn = (
|
||||
_cmd: string,
|
||||
_args: string[],
|
||||
callback: (err: ExecFileException | null, stdout: string, stderr: string) => void,
|
||||
) => {
|
||||
callback("string error" as unknown as ExecFileException, "", "");
|
||||
};
|
||||
|
||||
expect(
|
||||
convertFn("input.obj", "obj", "stl", "output.stl", undefined, mockExecFileStringError),
|
||||
).rejects.toMatch(/error:/i);
|
||||
}
|
||||
|
||||
export async function runConvertLogsStderror(convertFn: ConvertFnWithExecFile) {
|
||||
|
||||
Reference in New Issue
Block a user