# HG changeset patch # User Laman # Date 2019-06-29 14:49:04 # Node ID 9f2498ffdd4e9aa540bde66155a49e29a0305df0 # Parent 63e17c1c419e60b399652d968b2f1c769428b12c Jasmine tests diff --git a/.hgignore b/.hgignore new file mode 100644 --- /dev/null +++ b/.hgignore @@ -0,0 +1,1 @@ +^nbproject/ diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json new file mode 100644 --- /dev/null +++ b/spec/support/jasmine.json @@ -0,0 +1,11 @@ +{ + "spec_dir": "spec", + "spec_files": [ + "**/*[sS]pec.js" + ], + "helpers": [ + "helpers/**/*.js" + ], + "stopSpecOnExpectationFailure": false, + "random": true +} diff --git a/spec/test/utilSpec.js b/spec/test/utilSpec.js new file mode 100644 --- /dev/null +++ b/spec/test/utilSpec.js @@ -0,0 +1,27 @@ +/* global expect */ + +describe("Util",function(){ + var util = require("../../util.js"); + var utf=[ // https://tools.ietf.org/html/rfc3629#page-8 + ["",[]], + ["abc",[97,98,99]], + ["å",[195,165]], + ["🚅",[240,159,154,133]], + ["žír",[0xc5,0xbe,0xc3,0xad,114]], + ["A\u2262\u0391.",[0x41,0xE2,0x89,0xA2,0xCE,0x91,0x2E]], + ["\uD55C\uAD6D\uC5B4",[0xED,0x95,0x9C,0xEA,0xB5,0xAD,0xEC,0x96,0xB4]], + ["\ud84c\udfb4",[0xf0,0xa3,0x8e,0xb4]] + ]; + + describe("str2utf8",function(){ + it("should encode a String into bytes in UTF-8",function(){ + utf.forEach(couple=>expect(util.str2utf8(couple[0])).toEqual(couple[1])); + }); + }); + + describe("utf82str",function(){ + it("should decode a String from UTF-8 bytes",function(){ + utf.forEach(couple=>expect(util.utf82str(couple[1])).toEqual(couple[0])); + }); + }); +});