TypeScript/tests/cases/unittests/convertToBase64.ts

36 lines
1.3 KiB
TypeScript
Raw Normal View History

2015-06-11 21:01:19 +02:00
/// <reference path="..\..\..\src\harness\harness.ts" />
2015-04-08 07:54:06 +02:00
namespace ts {
describe("convertToBase64", () => {
2015-04-08 07:54:06 +02:00
function runTest(input: string): void {
const actual = ts.convertToBase64(input);
const expected = new Buffer(input).toString("base64");
2015-04-08 07:54:06 +02:00
assert.equal(actual, expected, "Encoded string using convertToBase64 does not match buffer.toString('base64')");
}
2016-04-01 21:41:45 +02:00
if (Buffer) {
it("Converts ASCII charaters correctly", () => {
runTest(" !\"#$ %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
});
2015-04-08 07:54:06 +02:00
2016-04-01 21:41:45 +02:00
it("Converts escape sequences correctly", () => {
runTest("\t\n\r\\\"\'\u0062");
});
2015-04-08 07:54:06 +02:00
2016-04-01 21:41:45 +02:00
it("Converts simple unicode characters correctly", () => {
runTest("ΠΣ ٵپ औठ ⺐⺠");
});
2015-04-08 07:54:06 +02:00
2016-04-01 21:41:45 +02:00
it("Converts simple code snippet correctly", () => {
runTest(`/// <reference path="file.ts" />
2015-04-08 07:54:06 +02:00
var x: string = "string";
console.log(x);`);
2016-04-01 21:41:45 +02:00
});
2015-04-08 07:54:06 +02:00
2016-04-01 21:41:45 +02:00
it("Converts simple code snippet with unicode characters correctly", () => {
runTest(`var Π = 3.1415; console.log(Π);`);
});
}
2015-04-08 07:54:06 +02:00
});
}