Test complete
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { readFileSync } from "fs"
|
||||
import { readFileSync, existsSync } from "fs"
|
||||
import { describe, it } from "mocha"
|
||||
import { resolve } from "path"
|
||||
import { expect } from "chai"
|
||||
@ -14,13 +14,20 @@ const equal = (name: Snapshot) => {
|
||||
const folder = resolve(__dirname, "snapshots", name)
|
||||
const actual = readFileSync(resolve(folder, "input.txt"), "utf-8")
|
||||
const expected = readFileSync(resolve(folder, "output.txt"), "utf-8")
|
||||
const babelrc: babel.TransformOptions = existsSync(resolve(folder, ".babelrc"))
|
||||
? JSON.parse(readFileSync(resolve(folder, ".babelrc"), "utf-8"))
|
||||
: {}
|
||||
|
||||
const transformed = transform(actual, {
|
||||
parserOpts: {
|
||||
...babelrc.parserOpts,
|
||||
plugins: ["decorators-legacy", "typescript"],
|
||||
},
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
presets: babelrc.presets,
|
||||
plugins: [
|
||||
...(babelrc.plugins ?? []),
|
||||
plugin,
|
||||
{
|
||||
visitor: {
|
||||
@ -52,11 +59,15 @@ describe("tsc-decorator", () => {
|
||||
equal("computedProperties")
|
||||
})
|
||||
|
||||
it("works with class/consrtuctor decorators", () => {
|
||||
it("works with class/constructor decorators", () => {
|
||||
equal("constructor")
|
||||
})
|
||||
|
||||
it("does not interfere with export declarations", () => {
|
||||
equal("exports")
|
||||
})
|
||||
|
||||
it("works with private properties", () => {
|
||||
equal("privateProperties")
|
||||
})
|
||||
})
|
||||
|
3
test/snapshots/privateProperties/.babelrc
Normal file
3
test/snapshots/privateProperties/.babelrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"presets": [["@babel/preset-env", { "targets": { "node": 14 } }]]
|
||||
}
|
4
test/snapshots/privateProperties/input.txt
Normal file
4
test/snapshots/privateProperties/input.txt
Normal file
@ -0,0 +1,4 @@
|
||||
@Service()
|
||||
export class B {
|
||||
#remote: Service
|
||||
}
|
22
test/snapshots/privateProperties/output.txt
Normal file
22
test/snapshots/privateProperties/output.txt
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true,
|
||||
});
|
||||
|
||||
exports.B = exports.B = void 0;
|
||||
|
||||
var _tslib = require("tslib");
|
||||
var _remote = /*#__PURE__*/ new WeakMap();
|
||||
|
||||
exports.B = exports.B = B = (0, _tslib.__decorate)([Service()], B);
|
||||
|
||||
class B {
|
||||
constructor() {
|
||||
_remote.set(this, {
|
||||
writable: true,
|
||||
value: void 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.B = exports.B = B;
|
Reference in New Issue
Block a user