X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/8c8953d378b20e194535e22214750367961b6963..fb3e0d562e2dbe9e3ea911a80bfdabc8851f92b2:/base64.test.js?ds=inline diff --git a/base64.test.js b/base64.test.js index e6361a4..84d9057 100755 --- a/base64.test.js +++ b/base64.test.js @@ -7,13 +7,15 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at . -import { a2b, b2a, isBase64 } from "./base64.js"; import { assert, assertEquals, assertStrictEquals, assertThrows, + describe, + it, } from "./dev-deps.js"; +import { a2b, b2a, isBase64 } from "./base64.js"; const base64s = { "AGIAYQBzAGUANgA0": "base64", @@ -24,17 +26,8 @@ const base64s = { ), }; -Deno.test({ - name: "Calling b2a returns the correct string.", - fn: () => - Object.entries(base64s).forEach(([key, value]) => - assertStrictEquals(b2a(value), key) - ), -}); - -Deno.test({ - name: "Calling a2b returns the correct data.", - fn: () => { +describe("a2b", () => { + it("[[Call]] returns the correct data", () => { assertEquals( a2b("AGIAYQBzAGUANgA0"), new Uint8Array( @@ -43,50 +36,53 @@ Deno.test({ ($) => $.charCodeAt(0), ), ).buffer, + "AGIAYQBzAGUANgA0", ); assertEquals( a2b("R/Q="), new Uint16Array([62535]).buffer, + "R/Q=", ); assertEquals( a2b("S0lCSQ=="), new Uint8ClampedArray([75, 73, 66, 73]).buffer, + "S0lCSQ==", ); assertEquals( a2b("YmFzZTY0"), new Uint8Array([98, 97, 115, 101, 54, 52]).buffer, + "YmFzZTY0", ); - }, -}); + }); -Deno.test({ - name: "Calling a2b throws when provided with an invalid character.", - fn: () => assertThrows(() => a2b("abc_")), -}); + it("[[Call]] throws when provided with an invalid character", () => { + assertThrows(() => a2b("abc_")); + }); -Deno.test({ - name: "Calling a2b throws when provided with an invalid equals.", - fn: () => assertThrows(() => a2b("abc==")), -}); + it("[[Call]] throws when provided with an invalid equals", () => { + assertThrows(() => a2b("abc==")); + }); -Deno.test({ - name: - "Calling a2b throws when provided with a length with a remainder of 1 when divided by 4.", - fn: () => { + it("[[Call]] throws when provided with a length with a remainder of 1 when divided by 4", () => { assertThrows(() => a2b("abcde")); assertThrows(() => a2b("abcde===")); - }, + }); }); -Deno.test({ - name: "isBase64 returns true for base64 strings.", - fn: () => - Object.keys(base64s).forEach((key) => assert(isBase64(key))), +describe("b2a", () => { + it("[[Call]] returns the correct string", () => { + Object.entries(base64s).forEach(([key, value]) => + assertStrictEquals(b2a(value), key) + ); + }); }); -Deno.test({ - name: "isBase64 returns false for others.", - fn: () => +describe("isBase64", () => { + it("[[Call]] returns true for base64 strings", () => { + Object.keys(base64s).forEach((key) => assert(isBase64(key))); + }); + + it("[[Call]] returns false for others", () => { [ undefined, null, @@ -101,5 +97,6 @@ Deno.test({ "abc_", "a", "abc==", - ].forEach((value) => assert(!isBase64(value))), + ].forEach((value) => assert(!isBase64(value))); + }); });