Closes #351. Update TypeScript beautification tests

This commit is contained in:
Glavin Wiechert 2015-05-20 12:18:38 -03:00
parent 25e2a754d5
commit f78fa314cd
4 changed files with 129 additions and 11 deletions

View File

@ -0,0 +1,56 @@
module XYZ {
interface I {
x: number,
y,
z
}
var zZz={
a: 123,
b: 456
};
enum En {
AB,
CD
}
var y=3;
switch(y {
case X:
console.log("x");
break;
default:
console.log("y");
}
if(x===3) {
if(y===4) {
console.log("hey");
}
console.log("x");
x=y.hey
.b
.c
.d;
export class X {
private x: number;
constructor() {
console.log("hi");
}
public mem() {
console.log("yes");
}
}
function xyz() {
function mem() {
console.log("yes");
}
}
}

View File

@ -0,0 +1,56 @@
module XYZ {
interface I {
x: number,
y,
z
}
var zZz={
a: 123,
b: 456
};
enum En {
AB,
CD
}
var y = 3;
switch(y {
case X:
console.log("x");
break;
default:
console.log("y");
}
if (x === 3) {
if (y === 4) {
console.log("hey");
}
console.log("x");
x = y.hey
.b
.c
.d;
export class X {
private x : number;
constructor() {
console.log("hi");
}
public mem() {
console.log("yes");
}
}
function xyz() {
function mem() {
console.log("yes");
}
}
}

View File

@ -8,15 +8,21 @@ module.exports = class TypeScriptFormatter extends Beautifier
}
beautify: (text, language, options) ->
return new @Promise((resolve, reject) ->
return new @Promise((resolve, reject) =>
format = require("typescript-formatter/lib/formatter")
opts = {}
opts.TabSize = options.tab_width
opts.TabSize = options.tab_width or options.indent_size
opts.IndentSize = options.indent_size
opts.IndentStyle = 'space'
opts.convertTabsToSpaces = true
@verbose('typescript', text, opts)
try
result = format(text, opts)
@verbose(result)
resolve result
catch e
return reject(e)
)