-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(integration-karma): migrate nested-template-event-target (#1207)
* test(integration-karma): migrate nested-template-event-target * test(integration-karma): migrate root-listener-event-target * test(integration-karma): migrate slotted-custome-element-event-target * test(integration-karma): migrate nested-render-conditional * test: increase timeout for two tests that flap in ie11
- Loading branch information
Showing
31 changed files
with
94 additions
and
162 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
packages/integration-karma/test/events/nested-template-event-target/index.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createElement } from 'test-utils'; | ||
import Container from 'x/container'; | ||
|
||
describe('Event target in slot elements', () => { | ||
it('should receive event with correct target', function() { | ||
const elm = createElement('x-container', { is: Container }); | ||
document.body.appendChild(elm); | ||
|
||
const child = elm.shadowRoot.querySelector('x-child'); | ||
|
||
child.dispatchFoo(); | ||
|
||
return Promise.resolve().then(() => { | ||
const elementWithResult = elm.shadowRoot.querySelector('.evt-target-is-x-child'); | ||
expect(elementWithResult).not.toBeNull(); | ||
expect(elementWithResult.innerText).toBe('Event Target Is x-child'); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...-target/nested-template-event-target.html → ...e-event-target/x/container/container.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<template> | ||
<integration-child onfoo={handleFoo}></integration-child> | ||
<x-child onfoo={handleFoo}></x-child> | ||
<div class="evt-target-is-x-child" if:true={evtTargetIsXChild}>Event Target Is x-child</div> | ||
</template> |
4 changes: 2 additions & 2 deletions
4
...nt-target/nested-template-event-target.js → ...ate-event-target/x/container/container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { LightningElement, track } from 'lwc'; | ||
|
||
export default class NestedTemplateEventTarget extends LightningElement { | ||
export default class Container extends LightningElement { | ||
@track | ||
evtTargetIsXChild = false; | ||
|
||
handleFoo(evt) { | ||
this.evtTargetIsXChild = evt.target.tagName.toLowerCase() === 'integration-child'; | ||
this.evtTargetIsXChild = evt.target.tagName.toLowerCase() === 'x-child'; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/integration-karma/test/events/root-listener-event-target/index.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { createElement } from 'test-utils'; | ||
import Container from 'x/container'; | ||
|
||
describe('Event target in slot elements', () => { | ||
it('should receive event with correct event.target in a shadowRoot listener', 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('.event-target-correct'); | ||
expect(elementWithResult).not.toBeNull(); | ||
expect(elementWithResult.innerText).toBe('Event Target is correct element'); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...event-target/integration/child/child.html → ...r-event-target/x/container/container.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<template> | ||
<integration-grand-child></integration-grand-child> | ||
<x-child></x-child> | ||
<div class="event-target-correct" if:true={eventTargetIsCorrect}>Event Target is correct element</div> | ||
</template> |
4 changes: 2 additions & 2 deletions
4
...r-event-target/integration/child/child.js → ...ner-event-target/x/container/container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { LightningElement, track } from 'lwc'; | ||
|
||
export default class Child extends LightningElement { | ||
export default class Container extends LightningElement { | ||
@track eventTargetIsCorrect = false; | ||
|
||
connectedCallback() { | ||
this.template.addEventListener('click', evt => { | ||
this.eventTargetIsCorrect = evt.target.tagName === 'INTEGRATION-GRAND-CHILD'; | ||
this.eventTargetIsCorrect = evt.target.tagName === 'X-CHILD'; | ||
}); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/integration-karma/test/events/slotted-custom-element-event-target/index.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
packages/integration-karma/test/events/slotted-custom-element-event-target/x/child/child.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Child extends LightningElement {} |
5 changes: 5 additions & 0 deletions
5
...egration-karma/test/events/slotted-custom-element-event-target/x/container/container.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<x-parent> | ||
<x-child></x-child> | ||
</x-parent> | ||
</template> |
3 changes: 3 additions & 0 deletions
3
...ntegration-karma/test/events/slotted-custom-element-event-target/x/container/container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { LightningElement } from 'lwc'; | ||
|
||
export default class Container extends LightningElement {} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
36 changes: 0 additions & 36 deletions
36
.../components/events/test-nested-template-event-target/nested-template-event-target.spec.js
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...rc/components/events/test-root-listener-event-target/integration/grandChild/grandChild.js
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...tener-event-target/integration/root-listener-event-target/root-listener-event-target.html
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...istener-event-target/integration/root-listener-event-target/root-listener-event-target.js
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
.../src/components/events/test-root-listener-event-target/root-listener-event-target.spec.js
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
.../integration/slotted-custom-element-event-target/slotted-custom-element-event-target.html
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...et/integration/slotted-custom-element-event-target/slotted-custom-element-event-target.js
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
...ents/test-slotted-custom-element-event-target/slotted-custom-element-event-target.spec.js
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...src/components/rendering/test-nested-render-conditional/nested-render-conditional.spec.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters