Added test for transpilation with emitting of metadata and decorator

This commit is contained in:
Sheetal Nandi 2015-08-24 12:47:39 -07:00
parent 3fdb5e8882
commit 2defe94b1f

View File

@ -220,6 +220,55 @@ var x = 0;`,
expectedOutput: output
});
});
it("Transpile with emit decorators and emit metadata", () => {
let input =
`import {db} from './db';\n` +
`function someDecorator(target) {\n` +
` return target;\n` +
`} \n` +
`@someDecorator\n` +
`class MyClass {\n` +
` db: db;\n` +
` constructor(db: db) {\n` +
` this.db = db;\n` +
` this.db.doSomething(); \n` +
` }\n` +
`}\n` +
`export {MyClass}; \n`
let output =
`var db_1 = require(\'./db\');\n` +
`function someDecorator(target) {\n` +
` return target;\n` +
`}\n` +
`var MyClass = (function () {\n` +
` function MyClass(db) {\n` +
` this.db = db;\n` +
` this.db.doSomething();\n` +
` }\n` +
` MyClass = __decorate([\n` +
` someDecorator, \n` +
` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` +
` ], MyClass);\n` +
` return MyClass;\n` +
` var _a;\n` +
`})();\n` +
`exports.MyClass = MyClass;\n`;
test(input,
{
options: {
compilerOptions: {
module: ModuleKind.CommonJS,
newLine: NewLineKind.LineFeed,
noEmitHelpers: true,
emitDecoratorMetadata: true,
experimentalDecorators: true,
target: ScriptTarget.ES5,
}
},
expectedOutput: output
});
});
});
}