• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1namespace ts {
2    describe("unittests:: convertToBase64", () => {
3        function runTest(input: string): void {
4            const actual = convertToBase64(input);
5            const expected = sys.base64encode!(input);
6            assert.equal(actual, expected, "Encoded string using convertToBase64 does not match buffer.toString('base64')");
7        }
8
9        if (Buffer) {
10            it("Converts ASCII charaters correctly", () => {
11                runTest(" !\"#$ %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
12            });
13
14            it("Converts escape sequences correctly", () => {
15                runTest("\t\n\r\\\"\'\u0062");
16            });
17
18            it("Converts simple unicode characters correctly", () => {
19                runTest("ΠΣ ٵپ औठ ⺐⺠");
20            });
21
22            it("Converts simple code snippet correctly", () => {
23                runTest(`/// <reference path="file.ts" />
24var x: string = "string";
25console.log(x);`);
26            });
27
28            it("Converts simple code snippet with unicode characters correctly", () => {
29                runTest(`var Π = 3.1415; console.log(Π);`);
30            });
31        }
32    });
33}
34