You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Use throw error instead of try-catch
This commit is contained in:
@@ -168,22 +168,15 @@ describe('export', function() {
|
|||||||
expect(textForFormat('HTML')).toBeTruthy();
|
expect(textForFormat('HTML')).toBeTruthy();
|
||||||
expect(textForFormat('JSON')).toBeTruthy();
|
expect(textForFormat('JSON')).toBeTruthy();
|
||||||
expect(textForFormat('PLAIN_TEXT')).toBeTruthy();
|
expect(textForFormat('PLAIN_TEXT')).toBeTruthy();
|
||||||
try {
|
expect(() => textForFormat('PDF')).toThrowError("Unknown format");
|
||||||
textForFormat('PDF');
|
|
||||||
throw new Error("Expected to throw an error");
|
|
||||||
} catch (e) {
|
|
||||||
expect(e.message).toBe("Unknown format");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checks if the export options are valid', function() {
|
it('checks if the export options are valid', function() {
|
||||||
for (const exportOption of invalidExportOptions) {
|
for (const exportOption of invalidExportOptions) {
|
||||||
try {
|
expect(
|
||||||
new PlainTextExporter(mockRoom, ExportType.Beginning, exportOption, null);
|
() =>
|
||||||
throw new Error("Expected to throw an error");
|
new PlainTextExporter(mockRoom, ExportType.Beginning, exportOption, null),
|
||||||
} catch (e) {
|
).toThrowError("Invalid export options");
|
||||||
expect(e.message).toBe("Invalid export options");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user