forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertToBase64.ts
More file actions
33 lines (28 loc) · 1.23 KB
/
convertToBase64.ts
File metadata and controls
33 lines (28 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace ts {
describe("unittests:: convertToBase64", () => {
function runTest(input: string): void {
const actual = convertToBase64(input);
const expected = sys.base64encode!(input);
assert.equal(actual, expected, "Encoded string using convertToBase64 does not match buffer.toString('base64')");
}
if (Buffer) {
it("Converts ASCII charaters correctly", () => {
runTest(" !\"#$ %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
});
it("Converts escape sequences correctly", () => {
runTest("\t\n\r\\\"\'\u0062");
});
it("Converts simple unicode characters correctly", () => {
runTest("ΠΣ ٵپ औठ ⺐⺠");
});
it("Converts simple code snippet correctly", () => {
runTest(`/// <reference path="file.ts" />
var x: string = "string";
console.log(x);`);
});
it("Converts simple code snippet with unicode characters correctly", () => {
runTest(`var Π = 3.1415; console.log(Π);`);
});
}
});
}