Skip to content

Commit

Permalink
test(integration-karma): migrate slotted-custome-element-event-target
Browse files Browse the repository at this point in the history
  • Loading branch information
jodarove committed May 3, 2019
1 parent a6b9d4a commit f391d45
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createElement } from 'test-utils';
import Container from 'x/container';

describe('Event target in slot elements', () => {
it('should receive event with correct target in slotted custom element', function() {
const elm = createElement('x-container', { is: Container });
document.body.appendChild(elm);

const child = elm.shadowRoot.querySelector('x-child');
child.click();

return Promise.resolve().then(() => {
const elementWithResult = elm.shadowRoot
.querySelector('x-parent')
.shadowRoot.querySelector('.correct-event-target');

expect(elementWithResult).not.toBeNull();
expect(elementWithResult.innerText).toBe('Event target is correct');
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<x-parent>
<x-child></x-child>
</x-parent>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { LightningElement } from 'lwc';

export default class Container extends LightningElement {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { LightningElement, track } from 'lwc';
export default class XParent extends LightningElement {
@track eventTargetIsCorrectTag = false;
handleClick(evt) {
this.eventTargetIsCorrectTag = evt.target.tagName === 'INTEGRATION-CHILD';
this.eventTargetIsCorrectTag = evt.target.tagName === 'X-CHILD';
}
}

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit f391d45

Please sign in to comment.