init
This commit is contained in:
56
jdenticon-js/test/unit/sha1.js
Normal file
56
jdenticon-js/test/unit/sha1.js
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
import tap from "tap";
|
||||
import { sha1 } from "../../src/common/sha1.js";
|
||||
|
||||
tap.equal("92cfceb39d57d914ed8b14d0e37643de0797ae56", sha1(42));
|
||||
tap.equal("21d90aad4d34f48f4aad9b5fa3c37c118af16df9", sha1("Value to be hashed"));
|
||||
tap.equal("d5d4cd07616a542891b7ec2d0257b3a24b69856e", sha1()); // undefined
|
||||
tap.equal("2be88ca4242c76e8253ac62474851065032d6833", sha1(null));
|
||||
tap.equal("08a73daac75982601504c4ba956f49e73ee52667", sha1("abcåäö")); // non-ASCII chars
|
||||
tap.equal("da39a3ee5e6b4b0d3255bfef95601890afd80709", sha1(""));
|
||||
tap.equal("11f6ad8ec52a2984abaafd7c3b516503785c2072", sha1("x"));
|
||||
|
||||
// The message is broken down to 64 byte blocks. Test the region around 64 bytes.
|
||||
|
||||
// 54 chars
|
||||
tap.equal("6d9fbf872b4e22afee77d8c9e95c10ec03bc731d", sha1("012345678901234567890123456789012345678901234567890123"));
|
||||
|
||||
// 55 chars
|
||||
tap.equal("9f3a4ce7f66b1b74c34da2c5d732c39f81e0f8df", sha1("0123456789012345678901234567890123456789012345678901234"));
|
||||
|
||||
// 56 chars
|
||||
tap.equal("0a40b8fbdaafb7c29651618ac15d27e772287130", sha1("01234567890123456789012345678901234567890123456789012345"));
|
||||
|
||||
// 57 chars
|
||||
tap.equal("46cc79601f8c6b81a4180774ce08465987a225a7", sha1("012345678901234567890123456789012345678901234567890123456"));
|
||||
|
||||
// 58 chars
|
||||
tap.equal("b2aac732d817277777547d2f067df99bb1b5c5ee", sha1("0123456789012345678901234567890123456789012345678901234567"));
|
||||
|
||||
// 59 chars
|
||||
tap.equal("beb7f3acc8e5c80ad813fb013406b58b0dc821ee", sha1("01234567890123456789012345678901234567890123456789012345678"));
|
||||
|
||||
// 60 chars
|
||||
tap.equal("f52e3c2732de7bea28f216d877d78dae1aa1ac6a", sha1("012345678901234567890123456789012345678901234567890123456789"));
|
||||
|
||||
// 61 chars
|
||||
tap.equal("2a1fc3a0fb3d5a6aac17068f5e12e3989269d221", sha1("0123456789012345678901234567890123456789012345678901234567890"));
|
||||
|
||||
// 62 chars
|
||||
tap.equal("bfbe32d71cb46704d9e185cb6b1e42e1b0965635", sha1("01234567890123456789012345678901234567890123456789012345678901"));
|
||||
|
||||
// 63 chars
|
||||
tap.equal("984b0f2f6d78c24020f5a79d409f67ab99302891", sha1("012345678901234567890123456789012345678901234567890123456789012"));
|
||||
|
||||
// 64 chars
|
||||
tap.equal("cf0800f7644ace3cb4c3fa33388d3ba0ea3c8b6e", sha1("0123456789012345678901234567890123456789012345678901234567890123"));
|
||||
|
||||
// 65 chars
|
||||
tap.equal("92de3a8444fe6d15268f0ba810aa43bc8b3a4ffe", sha1("01234567890123456789012345678901234567890123456789012345678901234"));
|
||||
|
||||
// 66 chars
|
||||
tap.equal("54af28647b3c9f53d5c20b2b7877062eb69a4675", sha1("012345678901234567890123456789012345678901234567890123456789012345"));
|
||||
|
||||
// 130 chars (spans three blocks)
|
||||
tap.equal("1f548f0569669daed4fee89712d9019e3d276b55", sha1("0123456789012345678901234567890123456789012345678901234567890123012345678901234567890123456789012345678901234567890123456789012345"));
|
||||
17
jdenticon-js/test/unit/toPng.js
Normal file
17
jdenticon-js/test/unit/toPng.js
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
import tap from "tap";
|
||||
import { toPng } from "../../src/node-esm.js";
|
||||
|
||||
const pngHash = toPng("Icon1", 100);
|
||||
const pngValue = toPng("9faff4f3d6d7d75577ce810ec6d6a06be49c3a5a", 100);
|
||||
|
||||
tap.ok(pngHash);
|
||||
tap.ok(pngHash instanceof Buffer);
|
||||
tap.ok(pngHash.length > 500);
|
||||
|
||||
tap.ok(pngValue);
|
||||
tap.ok(pngValue instanceof Buffer);
|
||||
tap.ok(pngValue.length > 500);
|
||||
|
||||
tap.ok(pngHash.equals(pngValue));
|
||||
9
jdenticon-js/test/unit/toSvg.js
Normal file
9
jdenticon-js/test/unit/toSvg.js
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
import tap from "tap";
|
||||
import { toSvg } from "../../src/node-esm.js";
|
||||
|
||||
const expectedSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path fill="#c0e5b2" d="M29 18.5L39.5 8L50 18.5L39.5 29ZM60.5 8L71 18.5L60.5 29L50 18.5ZM71 81.5L60.5 92L50 81.5L60.5 71ZM39.5 92L29 81.5L39.5 71L50 81.5ZM8 39.5L18.5 29L29 39.5L18.5 50ZM81.5 29L92 39.5L81.5 50L71 39.5ZM92 60.5L81.5 71L71 60.5L81.5 50ZM18.5 71L8 60.5L18.5 50L29 60.5Z"/><path fill="#81cc66" d="M11.5 18.5a7,7 0 1,1 14,0a7,7 0 1,1 -14,0M74.5 18.5a7,7 0 1,1 14,0a7,7 0 1,1 -14,0M74.5 81.5a7,7 0 1,1 14,0a7,7 0 1,1 -14,0M11.5 81.5a7,7 0 1,1 14,0a7,7 0 1,1 -14,0M50 29L50 45L40 29ZM71 50L55 50L71 40ZM50 71L50 55L60 71ZM29 50L45 50L29 60Z"/></svg>';
|
||||
|
||||
tap.equal(expectedSvg, toSvg("Icon1", 100));
|
||||
tap.equal(expectedSvg, toSvg("9faff4f3d6d7d75577ce810ec6d6a06be49c3a5a", 100));
|
||||
Reference in New Issue
Block a user