Skip to content

Commit 35c888e

Browse files
committed
chore(compat): disable tests related to has-listener in Vue 3
There is no way to answer, if we have listeners for even when using Vue3 compat build with $on available. Disable these tests for now, these could be enabled later, when INSTANCE_EVENT_EMITTER flag will be disabled
1 parent e65f802 commit 35c888e

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

src/components/table/table-tbody-row-events.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { mount } from '@vue/test-utils'
2+
import { isVue3 } from '../../vue'
23
import { waitNT } from '../../../tests/utils'
34
import { BTable } from './table'
45

@@ -245,6 +246,11 @@ describe('table > tbody row events', () => {
245246
})
246247

247248
it('should not emit row-hovered event when a row is hovered and no listener', async () => {
249+
if (isVue3) {
250+
// We can't track if we have an event listener in vue3 so we skip this test for vue 3
251+
return
252+
}
253+
248254
const wrapper = mount(BTable, {
249255
propsData: {
250256
fields: testFields,
@@ -309,6 +315,11 @@ describe('table > tbody row events', () => {
309315
})
310316

311317
it('should not emit row-unhovered event when a row is hovered and no listener', async () => {
318+
if (isVue3) {
319+
// We can't track if we have an event listener in vue3 so we skip this test for vue 3
320+
return
321+
}
322+
312323
const wrapper = mount(BTable, {
313324
propsData: {
314325
fields: testFields,

src/components/table/table-tbody-transition.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { config as vtuConfig, mount } from '@vue/test-utils'
22
import { TransitionGroupStub } from '../../../tests/components'
3+
import { isVue3 } from '../../vue'
34
import { BTable } from './table'
45

56
// Stub `<transition-group>` component
@@ -9,6 +10,14 @@ const testItems = [{ a: 1, b: 2, c: 3 }, { a: 5, b: 5, c: 6 }, { a: 7, b: 8, c:
910
const testFields = ['a', 'b', 'c']
1011

1112
describe('table > tbody transition', () => {
13+
if (isVue3) {
14+
// @vue/test-utils does not support stubbing transition, so impossible to test ATM
15+
16+
// adding dummy test to keep jest happy
17+
it('skipped due to vue3', () => {})
18+
return
19+
}
20+
1221
it('tbody should not be a transition-group component by default', async () => {
1322
const wrapper = mount(BTable, {
1423
attachTo: document.body,

src/components/table/table-thead-events.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { mount } from '@vue/test-utils'
2+
import { isVue3 } from '../../vue'
23
import { BTable } from './table'
34

45
const testItems = [{ a: 1, b: 2, c: 3 }]
56
const testFields = [{ key: 'a', label: 'A' }, { key: 'b', label: 'B' }, { key: 'c', label: 'C' }]
67

78
describe('table > thead events', () => {
89
it('should not emit head-clicked event when a head cell is clicked and no head-clicked listener', async () => {
10+
if (isVue3) {
11+
// We can't track if we have an event listener in vue3 so we skip this test for vue 3
12+
return
13+
}
914
const wrapper = mount(BTable, {
1015
propsData: {
1116
fields: testFields,

src/mixins/has-listener.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
// either via `v-on:name` (in the parent) or programmatically
33
// via `vm.$on('name', ...)`
44
// See: https://github.com/vuejs/vue/issues/10825
5-
import { Vue } from '../vue'
5+
import { isVue3, Vue } from '../vue'
66
import { isArray, isUndefined } from '../utils/inspect'
77

88
// @vue/component
99
export const hasListenerMixin = Vue.extend({
1010
methods: {
1111
hasListener(name) {
12+
if (isVue3) {
13+
return true
14+
}
1215
// Only includes listeners registered via `v-on:name`
1316
const $listeners = this.$listeners || {}
1417
// Includes `v-on:name` and `this.$on('name')` registered listeners

0 commit comments

Comments
 (0)