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/text_encoding_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/text_encoding_test.ts')
-rw-r--r-- | cli/js/text_encoding_test.ts | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/cli/js/text_encoding_test.ts b/cli/js/text_encoding_test.ts index 28f23511a..e85655feb 100644 --- a/cli/js/text_encoding_test.ts +++ b/cli/js/text_encoding_test.ts @@ -1,19 +1,19 @@ // 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"; -test(function btoaSuccess(): void { +unitTest(function btoaSuccess(): void { const text = "hello world"; const encoded = btoa(text); assertEquals(encoded, "aGVsbG8gd29ybGQ="); }); -test(function atobSuccess(): void { +unitTest(function atobSuccess(): void { const encoded = "aGVsbG8gd29ybGQ="; const decoded = atob(encoded); assertEquals(decoded, "hello world"); }); -test(function atobWithAsciiWhitespace(): void { +unitTest(function atobWithAsciiWhitespace(): void { const encodedList = [ " aGVsbG8gd29ybGQ=", " aGVsbG8gd29ybGQ=", @@ -30,7 +30,7 @@ test(function atobWithAsciiWhitespace(): void { } }); -test(function atobThrows(): void { +unitTest(function atobThrows(): void { let threw = false; try { atob("aGVsbG8gd29ybGQ=="); @@ -40,7 +40,7 @@ test(function atobThrows(): void { assert(threw); }); -test(function atobThrows2(): void { +unitTest(function atobThrows2(): void { let threw = false; try { atob("aGVsbG8gd29ybGQ==="); @@ -50,7 +50,7 @@ test(function atobThrows2(): void { assert(threw); }); -test(function btoaFailed(): void { +unitTest(function btoaFailed(): void { const text = "你好"; let err; try { @@ -62,7 +62,7 @@ test(function btoaFailed(): void { assert(err instanceof TypeError); }); -test(function textDecoder2(): void { +unitTest(function textDecoder2(): void { // prettier-ignore const fixture = new Uint8Array([ 0xf0, 0x9d, 0x93, 0xbd, @@ -74,7 +74,7 @@ test(function textDecoder2(): void { assertEquals(decoder.decode(fixture), "𝓽𝓮𝔁𝓽"); }); -test(function textDecoderIgnoreBOM(): void { +unitTest(function textDecoderIgnoreBOM(): void { // prettier-ignore const fixture = new Uint8Array([ 0xef, 0xbb, 0xbf, @@ -87,7 +87,7 @@ test(function textDecoderIgnoreBOM(): void { assertEquals(decoder.decode(fixture), "𝓽𝓮𝔁𝓽"); }); -test(function textDecoderNotBOM(): void { +unitTest(function textDecoderNotBOM(): void { // prettier-ignore const fixture = new Uint8Array([ 0xef, 0xbb, 0x89, @@ -100,13 +100,13 @@ test(function textDecoderNotBOM(): void { assertEquals(decoder.decode(fixture), "ﻉ𝓽𝓮𝔁𝓽"); }); -test(function textDecoderASCII(): void { +unitTest(function textDecoderASCII(): void { const fixture = new Uint8Array([0x89, 0x95, 0x9f, 0xbf]); const decoder = new TextDecoder("ascii"); assertEquals(decoder.decode(fixture), "‰•Ÿ¿"); }); -test(function textDecoderErrorEncoding(): void { +unitTest(function textDecoderErrorEncoding(): void { let didThrow = false; try { new TextDecoder("foo"); @@ -117,7 +117,7 @@ test(function textDecoderErrorEncoding(): void { assert(didThrow); }); -test(function textEncoder(): void { +unitTest(function textEncoder(): void { const fixture = "𝓽𝓮𝔁𝓽"; const encoder = new TextEncoder(); // prettier-ignore @@ -129,7 +129,7 @@ test(function textEncoder(): void { ]); }); -test(function textEncodeInto(): void { +unitTest(function textEncodeInto(): void { const fixture = "text"; const encoder = new TextEncoder(); const bytes = new Uint8Array(5); @@ -142,7 +142,7 @@ test(function textEncodeInto(): void { ]); }); -test(function textEncodeInto2(): void { +unitTest(function textEncodeInto2(): void { const fixture = "𝓽𝓮𝔁𝓽"; const encoder = new TextEncoder(); const bytes = new Uint8Array(17); @@ -158,7 +158,7 @@ test(function textEncodeInto2(): void { ]); }); -test(function textDecoderSharedUint8Array(): void { +unitTest(function textDecoderSharedUint8Array(): void { const ab = new SharedArrayBuffer(6); const dataView = new DataView(ab); const charCodeA = "A".charCodeAt(0); @@ -171,7 +171,7 @@ test(function textDecoderSharedUint8Array(): void { assertEquals(actual, "ABCDEF"); }); -test(function textDecoderSharedInt32Array(): void { +unitTest(function textDecoderSharedInt32Array(): void { const ab = new SharedArrayBuffer(8); const dataView = new DataView(ab); const charCodeA = "A".charCodeAt(0); @@ -184,7 +184,7 @@ test(function textDecoderSharedInt32Array(): void { assertEquals(actual, "ABCDEFGH"); }); -test(function toStringShouldBeWebCompatibility(): void { +unitTest(function toStringShouldBeWebCompatibility(): void { const encoder = new TextEncoder(); assertEquals(encoder.toString(), "[object TextEncoder]"); |