Skip to content
Permalink
Browse files
test: add test for babel
  • Loading branch information
ktsn committed Oct 9, 2018
1 parent 42005ad commit 5f0ecc274048dcb0455fc4861f5cd2d7e71ca695
Showing with 30 additions and 7 deletions.
  1. +2 −2 src/reflect.ts
  2. +27 −0 test/test-babel.js
  3. +1 −5 test/test.ts
@@ -11,11 +11,11 @@ export function copyReflectionMetadata (
) {
forwardMetadata(to, from)

Object.keys(from.prototype).forEach(key => {
Object.getOwnPropertyNames(from.prototype).forEach(key => {
forwardMetadata(to.prototype, from.prototype, key)
})

Object.keys(from).forEach(key => {
Object.getOwnPropertyNames(from).forEach(key => {
forwardMetadata(to, from, key)
})
}
@@ -1,3 +1,4 @@
import 'reflect-metadata'
import Component, { createDecorator, mixins } from '../lib'
import { expect } from 'chai'
import * as td from 'testdouble'
@@ -148,4 +149,30 @@ describe('vue-class-component with Babel', () => {
expect(vm.valueA).to.equal('hi')
expect(vm.valueB).to.equal(456)
})

it('copies reflection metadata', function () {
@Component
@Reflect.metadata('worksConstructor', true)
class Test extends Vue {
@Reflect.metadata('worksStatic', true)
static staticValue = 'staticValue'

_test = false

@Reflect.metadata('worksMethod', true)
test () {
void 0
}

@Reflect.metadata('worksAccessor', true)
get testAccessor () {
return this._test
}
}

expect(Reflect.getOwnMetadata('worksConstructor', Test)).to.equal(true)
expect(Reflect.getOwnMetadata('worksStatic', Test, 'staticValue')).to.equal(true)
expect(Reflect.getOwnMetadata('worksMethod', Test.prototype, 'test')).to.equal(true)
expect(Reflect.getOwnMetadata('worksAccessor', Test.prototype, 'testAccessor')).to.equal(true)
})
})
@@ -378,7 +378,7 @@ describe('vue-class-component', () => {
@Reflect.metadata('worksStatic', true)
static staticValue: string = 'staticValue'

private _test: boolean = false;
private _test: boolean = false

@Reflect.metadata('worksMethod', true)
test (): void {
@@ -389,10 +389,6 @@ describe('vue-class-component', () => {
get testAccessor (): boolean {
return this._test
}

set testAccessor (value: boolean) {
this._test = value
}
}

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

0 comments on commit 5f0ecc2

Please sign in to comment.