mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-29 12:41:42 +00:00
Merge branch 'master' into demo-alternate-store
This commit is contained in:
@@ -48,6 +48,29 @@ describe("Utility tests", function() {
|
||||
expect($tw.utils.base64Decode($tw.utils.base64Encode(booksEmoji))).toBe(booksEmoji, "should round-trip correctly");
|
||||
});
|
||||
|
||||
it("should handle base64 encoding emojis in URL-safe variant", function() {
|
||||
var booksEmoji = "📚";
|
||||
expect($tw.utils.base64Encode(booksEmoji, false, true)).toBe("8J-Tmg==", "if surrogate pairs are correctly treated as a single code unit then base64 should be 8J+Tmg==");
|
||||
expect($tw.utils.base64Decode("8J-Tmg==", false, true)).toBe(booksEmoji);
|
||||
expect($tw.utils.base64Decode($tw.utils.base64Encode(booksEmoji, false, true), false, true)).toBe(booksEmoji, "should round-trip correctly");
|
||||
});
|
||||
|
||||
it("should handle base64 encoding binary data", function() {
|
||||
var binaryData = "\xff\xfe\xfe\xff";
|
||||
var encoded = $tw.utils.base64Encode(binaryData,true);
|
||||
expect(encoded).toBe("//7+/w==");
|
||||
var decoded = $tw.utils.base64Decode(encoded,true);
|
||||
expect(decoded).toBe(binaryData, "Binary data did not round-trip correctly");
|
||||
});
|
||||
|
||||
it("should handle base64 encoding binary data in URL-safe variant", function() {
|
||||
var binaryData = "\xff\xfe\xfe\xff";
|
||||
var encoded = $tw.utils.base64Encode(binaryData,true,true);
|
||||
expect(encoded).toBe("__7-_w==");
|
||||
var decoded = $tw.utils.base64Decode(encoded,true,true);
|
||||
expect(decoded).toBe(binaryData, "Binary data did not round-trip correctly");
|
||||
});
|
||||
|
||||
it("should handle stringifying a string array", function() {
|
||||
var str = $tw.utils.stringifyList;
|
||||
expect(str([])).toEqual("");
|
||||
|
||||
Reference in New Issue
Block a user