From 9cbdc4a6136ab8c0a4ed87dcd9b2fe5a882af183 Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Fri, 13 Aug 2021 08:34:54 +0530 Subject: [PATCH] Use throw error instead of try-catch --- test/utils/export-test.tsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/test/utils/export-test.tsx b/test/utils/export-test.tsx index c23f15c24b..c4d9b43765 100644 --- a/test/utils/export-test.tsx +++ b/test/utils/export-test.tsx @@ -168,22 +168,15 @@ describe('export', function() { expect(textForFormat('HTML')).toBeTruthy(); expect(textForFormat('JSON')).toBeTruthy(); expect(textForFormat('PLAIN_TEXT')).toBeTruthy(); - try { - textForFormat('PDF'); - throw new Error("Expected to throw an error"); - } catch (e) { - expect(e.message).toBe("Unknown format"); - } + expect(() => textForFormat('PDF')).toThrowError("Unknown format"); }); it('checks if the export options are valid', function() { for (const exportOption of invalidExportOptions) { - try { - new PlainTextExporter(mockRoom, ExportType.Beginning, exportOption, null); - throw new Error("Expected to throw an error"); - } catch (e) { - expect(e.message).toBe("Invalid export options"); - } + expect( + () => + new PlainTextExporter(mockRoom, ExportType.Beginning, exportOption, null), + ).toThrowError("Invalid export options"); } });