|
|
@@ -232,7 +232,12 @@ describe('defineCustomElement', () => {
|
|
|
emit('created')
|
|
|
return () =>
|
|
|
h('div', {
|
|
|
- onClick: () => emit('my-click', 1)
|
|
|
+ onClick: () => {
|
|
|
+ emit('my-click', 1)
|
|
|
+ },
|
|
|
+ onMousedown: () => {
|
|
|
+ emit('myEvent', 1) // validate hypenization
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
@@ -252,11 +257,26 @@ describe('defineCustomElement', () => {
|
|
|
const spy = jest.fn()
|
|
|
e.addEventListener('my-click', spy)
|
|
|
e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
|
|
|
- expect(spy).toHaveBeenCalled()
|
|
|
+ expect(spy).toHaveBeenCalledTimes(1)
|
|
|
expect(spy.mock.calls[0][0]).toMatchObject({
|
|
|
detail: [1]
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+ // #5373
|
|
|
+ test('case transform for camelCase event', () => {
|
|
|
+ container.innerHTML = `<my-el-emits></my-el-emits>`
|
|
|
+ const e = container.childNodes[0] as VueElement
|
|
|
+ const spy1 = jest.fn()
|
|
|
+ e.addEventListener('myEvent', spy1)
|
|
|
+ const spy2 = jest.fn()
|
|
|
+ // emitting myEvent, but listening for my-event. This happens when
|
|
|
+ // using the custom element in a Vue template
|
|
|
+ e.addEventListener('my-event', spy2)
|
|
|
+ e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('mousedown'))
|
|
|
+ expect(spy1).toHaveBeenCalledTimes(1)
|
|
|
+ expect(spy2).toHaveBeenCalledTimes(1)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('slots', () => {
|