Skip to content

Commit 5f0ecc2

Browse files
committed
test: add test for babel
1 parent 42005ad commit 5f0ecc2

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

src/reflect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export function copyReflectionMetadata (
1111
) {
1212
forwardMetadata(to, from)
1313

14-
Object.keys(from.prototype).forEach(key => {
14+
Object.getOwnPropertyNames(from.prototype).forEach(key => {
1515
forwardMetadata(to.prototype, from.prototype, key)
1616
})
1717

18-
Object.keys(from).forEach(key => {
18+
Object.getOwnPropertyNames(from).forEach(key => {
1919
forwardMetadata(to, from, key)
2020
})
2121
}

test/test-babel.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'reflect-metadata'
12
import Component, { createDecorator, mixins } from '../lib'
23
import { expect } from 'chai'
34
import * as td from 'testdouble'
@@ -148,4 +149,30 @@ describe('vue-class-component with Babel', () => {
148149
expect(vm.valueA).to.equal('hi')
149150
expect(vm.valueB).to.equal(456)
150151
})
152+
153+
it('copies reflection metadata', function () {
154+
@Component
155+
@Reflect.metadata('worksConstructor', true)
156+
class Test extends Vue {
157+
@Reflect.metadata('worksStatic', true)
158+
static staticValue = 'staticValue'
159+
160+
_test = false
161+
162+
@Reflect.metadata('worksMethod', true)
163+
test () {
164+
void 0
165+
}
166+
167+
@Reflect.metadata('worksAccessor', true)
168+
get testAccessor () {
169+
return this._test
170+
}
171+
}
172+
173+
expect(Reflect.getOwnMetadata('worksConstructor', Test)).to.equal(true)
174+
expect(Reflect.getOwnMetadata('worksStatic', Test, 'staticValue')).to.equal(true)
175+
expect(Reflect.getOwnMetadata('worksMethod', Test.prototype, 'test')).to.equal(true)
176+
expect(Reflect.getOwnMetadata('worksAccessor', Test.prototype, 'testAccessor')).to.equal(true)
177+
})
151178
})

test/test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ describe('vue-class-component', () => {
378378
@Reflect.metadata('worksStatic', true)
379379
static staticValue: string = 'staticValue'
380380

381-
private _test: boolean = false;
381+
private _test: boolean = false
382382

383383
@Reflect.metadata('worksMethod', true)
384384
test (): void {
@@ -389,10 +389,6 @@ describe('vue-class-component', () => {
389389
get testAccessor (): boolean {
390390
return this._test
391391
}
392-
393-
set testAccessor (value: boolean) {
394-
this._test = value
395-
}
396392
}
397393

398394
expect(Reflect.getOwnMetadata('worksConstructor', Test)).to.equal(true)

0 commit comments

Comments
 (0)