diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2020-03-04 17:31:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-04 17:31:14 +0100 |
commit | 8d96dffa410a149d0fff6115bd97f41fc1fe7459 (patch) | |
tree | b00dc7a78e5030b68741de8bf9dde83b9fa07364 /cli/js/file_test.ts | |
parent | 30682cf74fa039d3493c74101dca2dbb3a8d49b6 (diff) |
refactor: rewrite testPerm into unitTest (#4231)
Rewrite "testPerm" helper function used for testing of internal
runtime code. It's been renamed to "unitTest" and provides API that
is extensible in the future by accepting optional "UnitTestOptions"
argument. "test" helper was also removed and replaced by
overloaded version of "unitTest" that takes only function argument.
"UnitTestOptions" currently supports "perms" and "skip"
options, where former works exactly as first argument to "testPerm"
did, while the latter allows to conditionally skip tests.
Diffstat (limited to 'cli/js/file_test.ts')
-rw-r--r-- | cli/js/file_test.ts | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/cli/js/file_test.ts b/cli/js/file_test.ts index 8fc37f701..1a7a5f88b 100644 --- a/cli/js/file_test.ts +++ b/cli/js/file_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test, assert, assertEquals } from "./test_util.ts"; +import { unitTest, assert, assertEquals } from "./test_util.ts"; // eslint-disable-next-line @typescript-eslint/no-explicit-any function testFirstArgument(arg1: any[], expectedSize: number): void { @@ -10,47 +10,47 @@ function testFirstArgument(arg1: any[], expectedSize: number): void { assertEquals(file.type, ""); } -test(function fileEmptyFileBits(): void { +unitTest(function fileEmptyFileBits(): void { testFirstArgument([], 0); }); -test(function fileStringFileBits(): void { +unitTest(function fileStringFileBits(): void { testFirstArgument(["bits"], 4); }); -test(function fileUnicodeStringFileBits(): void { +unitTest(function fileUnicodeStringFileBits(): void { testFirstArgument(["𝓽𝓮𝔁𝓽"], 16); }); -test(function fileStringObjectFileBits(): void { +unitTest(function fileStringObjectFileBits(): void { testFirstArgument([new String("string object")], 13); }); -test(function fileEmptyBlobFileBits(): void { +unitTest(function fileEmptyBlobFileBits(): void { testFirstArgument([new Blob()], 0); }); -test(function fileBlobFileBits(): void { +unitTest(function fileBlobFileBits(): void { testFirstArgument([new Blob(["bits"])], 4); }); -test(function fileEmptyFileFileBits(): void { +unitTest(function fileEmptyFileFileBits(): void { testFirstArgument([new File([], "world.txt")], 0); }); -test(function fileFileFileBits(): void { +unitTest(function fileFileFileBits(): void { testFirstArgument([new File(["bits"], "world.txt")], 4); }); -test(function fileArrayBufferFileBits(): void { +unitTest(function fileArrayBufferFileBits(): void { testFirstArgument([new ArrayBuffer(8)], 8); }); -test(function fileTypedArrayFileBits(): void { +unitTest(function fileTypedArrayFileBits(): void { testFirstArgument([new Uint8Array([0x50, 0x41, 0x53, 0x53])], 4); }); -test(function fileVariousFileBits(): void { +unitTest(function fileVariousFileBits(): void { testFirstArgument( [ "bits", @@ -64,15 +64,15 @@ test(function fileVariousFileBits(): void { ); }); -test(function fileNumberInFileBits(): void { +unitTest(function fileNumberInFileBits(): void { testFirstArgument([12], 2); }); -test(function fileArrayInFileBits(): void { +unitTest(function fileArrayInFileBits(): void { testFirstArgument([[1, 2, 3]], 5); }); -test(function fileObjectInFileBits(): void { +unitTest(function fileObjectInFileBits(): void { // "[object Object]" testFirstArgument([{}], 15); }); @@ -84,22 +84,22 @@ function testSecondArgument(arg2: any, expectedFileName: string): void { assertEquals(file.name, expectedFileName); } -test(function fileUsingFileName(): void { +unitTest(function fileUsingFileName(): void { testSecondArgument("dummy", "dummy"); }); -test(function fileUsingSpecialCharacterInFileName(): void { +unitTest(function fileUsingSpecialCharacterInFileName(): void { testSecondArgument("dummy/foo", "dummy:foo"); }); -test(function fileUsingNullFileName(): void { +unitTest(function fileUsingNullFileName(): void { testSecondArgument(null, "null"); }); -test(function fileUsingNumberFileName(): void { +unitTest(function fileUsingNumberFileName(): void { testSecondArgument(1, "1"); }); -test(function fileUsingEmptyStringFileName(): void { +unitTest(function fileUsingEmptyStringFileName(): void { testSecondArgument("", ""); }); |