Skip to content

Commit 93ad922

Browse files
committed
test: Add a test to demonstrate dangerous mixins
1 parent 29e9c79 commit 93ad922

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,36 @@ describe('vue-class-component', () => {
401401
expect(vm.valueB).to.equal(456)
402402
})
403403

404+
it('mixins should be safe with VueContructor and global mixins', function () {
405+
let counter = 0
406+
407+
/**
408+
* dangerous global mixin
409+
*/
410+
Vue.mixin({
411+
created() {
412+
counter++
413+
}
414+
})
415+
416+
@Component
417+
class MixinA extends Vue {
418+
}
419+
420+
@Component
421+
class MixinB extends Vue {
422+
}
423+
424+
@Component
425+
class MyComp extends mixins(MixinA, MixinB) {
426+
test() {}
427+
}
428+
429+
const vm = new MyComp()
430+
vm.test() // just to avoid 'noUnusedLocals' error
431+
expect(counter).to.equal(0)
432+
})
433+
404434
it('copies reflection metadata', function () {
405435
@Component
406436
@Reflect.metadata('worksConstructor', true)

0 commit comments

Comments
 (0)