From 87f8f99c49e62c06f85bb453a7c12b32634c3bef Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Thu, 25 Jun 2020 06:57:08 +0800 Subject: refactor(cli/tests/unit) to use assertThrows (#6459) --- cli/tests/unit/buffer_test.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'cli/tests/unit/buffer_test.ts') diff --git a/cli/tests/unit/buffer_test.ts b/cli/tests/unit/buffer_test.ts index c5a63b5c8..644f05952 100644 --- a/cli/tests/unit/buffer_test.ts +++ b/cli/tests/unit/buffer_test.ts @@ -6,7 +6,6 @@ import { assertEquals, assert, - assertStringContains, assertThrows, assertThrowsAsync, unitTest, @@ -159,15 +158,13 @@ unitTest(async function bufferTooLargeByteWrites(): Promise { const buf = new Deno.Buffer(xBytes.buffer as ArrayBuffer); await buf.read(tmp); - let err; - try { - buf.grow(growLen); - } catch (e) { - err = e; - } - - assert(err instanceof Error); - assertStringContains(err.message, "grown beyond the maximum size"); + assertThrows( + () => { + buf.grow(growLen); + }, + Error, + "grown beyond the maximum size" + ); }); unitTest(async function bufferLargeByteReads(): Promise { -- cgit v1.2.3