Add more tests
This commit is contained in:
parent
6121d64756
commit
6f28290529
@ -10,6 +10,11 @@ interface State {
|
||||
|
||||
export default ({ types: t }: typeof babel): babel.PluginObj<State> => ({
|
||||
name: "tsc-decorators",
|
||||
manipulateOptions(_, { plugins }) {
|
||||
if (!plugins.includes("decorators-legacy")) {
|
||||
plugins.push("decorators-legacy")
|
||||
}
|
||||
},
|
||||
visitor: {
|
||||
Program: {
|
||||
enter(path, state) {
|
||||
|
@ -20,9 +20,18 @@ const equal = (name: Snapshot) => {
|
||||
},
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
plugins: [plugin],
|
||||
plugins: [
|
||||
plugin,
|
||||
{
|
||||
visitor: {
|
||||
ClassProperty(path) {
|
||||
delete path.node.definite
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
})!.code!
|
||||
expect(canonize(transformed)).to.deep.equal(canonize(expected))
|
||||
expect(canonize(transformed) + "\n").to.deep.equal(canonize(expected) + "\n")
|
||||
}
|
||||
|
||||
describe("tsc-decorator", () => {
|
||||
|
@ -2,4 +2,11 @@ class A {
|
||||
@dec prop: string
|
||||
@dec @dec2 prop2: string
|
||||
@dec static staticProp: number
|
||||
@called() service: Service
|
||||
ignored: boolean
|
||||
}
|
||||
|
||||
@Service()
|
||||
export class B {
|
||||
@Service() remote!: Service
|
||||
}
|
@ -4,8 +4,18 @@ class A {
|
||||
prop: string;
|
||||
prop2: string;
|
||||
static staticProp: number;
|
||||
service: Service;
|
||||
ignored: boolean;
|
||||
}
|
||||
|
||||
__decorate([dec], A.prototype, "prop", void 0);
|
||||
__decorate([dec, dec2], A.prototype, "prop2", void 0);
|
||||
__decorate([dec], A, "staticProp", void 0);
|
||||
__decorate([dec], A, "staticProp", void 0);
|
||||
__decorate([called()], A.prototype, "service", void 0);
|
||||
|
||||
let B = class B {
|
||||
remote: Service;
|
||||
};
|
||||
__decorate([Service()], B.prototype, "remote", void 0);
|
||||
B = __decorate([Service()], B);
|
||||
export { B };
|
Loading…
x
Reference in New Issue
Block a user