Skip to content

Commit 2defe94

Browse files
committed
Added test for transpilation with emitting of metadata and decorator
1 parent 3fdb5e8 commit 2defe94

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/cases/unittests/transpile.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,55 @@ var x = 0;`,
220220
expectedOutput: output
221221
});
222222
});
223+
224+
it("Transpile with emit decorators and emit metadata", () => {
225+
let input =
226+
`import {db} from './db';\n` +
227+
`function someDecorator(target) {\n` +
228+
` return target;\n` +
229+
`} \n` +
230+
`@someDecorator\n` +
231+
`class MyClass {\n` +
232+
` db: db;\n` +
233+
` constructor(db: db) {\n` +
234+
` this.db = db;\n` +
235+
` this.db.doSomething(); \n` +
236+
` }\n` +
237+
`}\n` +
238+
`export {MyClass}; \n`
239+
let output =
240+
`var db_1 = require(\'./db\');\n` +
241+
`function someDecorator(target) {\n` +
242+
` return target;\n` +
243+
`}\n` +
244+
`var MyClass = (function () {\n` +
245+
` function MyClass(db) {\n` +
246+
` this.db = db;\n` +
247+
` this.db.doSomething();\n` +
248+
` }\n` +
249+
` MyClass = __decorate([\n` +
250+
` someDecorator, \n` +
251+
` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` +
252+
` ], MyClass);\n` +
253+
` return MyClass;\n` +
254+
` var _a;\n` +
255+
`})();\n` +
256+
`exports.MyClass = MyClass;\n`;
223257

258+
test(input,
259+
{
260+
options: {
261+
compilerOptions: {
262+
module: ModuleKind.CommonJS,
263+
newLine: NewLineKind.LineFeed,
264+
noEmitHelpers: true,
265+
emitDecoratorMetadata: true,
266+
experimentalDecorators: true,
267+
target: ScriptTarget.ES5,
268+
}
269+
},
270+
expectedOutput: output
271+
});
272+
});
224273
});
225274
}

0 commit comments

Comments
 (0)