-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix event tests to be shadow aware (#1182)
* fix: fix event tests to be shadow aware * test: more stuff * test: address pr comments
- Loading branch information
1 parent
4a83510
commit 3cd1191
Showing
33 changed files
with
331 additions
and
166 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
packages/integration-karma/test/shadow-dom/Event-properties/Event.defaultPrevented.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,12 @@ | ||
import { createElement } from 'lwc'; | ||
import XDefaultPreventingParent from 'x/defaultPreventingParent'; | ||
|
||
it('defaultPrevented should be true after preventDefault() is invoked', function() { | ||
const elm = createElement('x-default-prevented-parent', { is: XDefaultPreventingParent }); | ||
document.body.appendChild(elm); | ||
const child = elm.shadowRoot.querySelector('x-default-prevented-child'); | ||
child.dispatchCancelableEvent(); | ||
|
||
expect(elm.defaultPrevented).toBe(true); | ||
expect(child.defaultPrevented).toBe(true); | ||
}); |
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
1 change: 0 additions & 1 deletion
1
...lt-prevented/integration/child/child.html → ...PreventedChild/defaultPreventedChild.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,3 @@ | ||
<template> | ||
<span onclick={handleClick}>Child</span> | ||
<div if:true={defaultPrevented} class="default-prevented-indicator">Default Prevented</div> | ||
</template> |
18 changes: 18 additions & 0 deletions
18
...n-karma/test/shadow-dom/Event-properties/x/defaultPreventedChild/defaultPreventedChild.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 { LightningElement, api } from 'lwc'; | ||
|
||
export default class Child extends LightningElement { | ||
_defaultPrevented = false; | ||
@api | ||
get defaultPrevented() { | ||
return this._defaultPrevented; | ||
} | ||
|
||
@api | ||
dispatchCancelableEvent() { | ||
const event = new CustomEvent('foo', { | ||
cancelable: true, | ||
}); | ||
this.dispatchEvent(event); | ||
this._defaultPrevented = event.defaultPrevented; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...a/test/shadow-dom/Event-properties/x/defaultPreventingParent/defaultPreventingParent.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,3 @@ | ||
<template> | ||
<x-default-prevented-child onfoo={handleFoo}></x-default-prevented-child> | ||
</template> |
9 changes: 9 additions & 0 deletions
9
...rma/test/shadow-dom/Event-properties/x/defaultPreventingParent/defaultPreventingParent.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,9 @@ | ||
import { LightningElement, api } from 'lwc'; | ||
|
||
export default class DefaultPreventingParent extends LightningElement { | ||
@api defaultPrevented = false; | ||
handleFoo(evt) { | ||
evt.preventDefault(); | ||
this.defaultPrevented = evt.defaultPrevented; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...karma/test/shadow-dom/Event-properties/x/documentEventListener/documentEventListener.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,3 @@ | ||
<template> | ||
<button>Click Me</button> | ||
</template> |
3 changes: 3 additions & 0 deletions
3
...n-karma/test/shadow-dom/Event-properties/x/documentEventListener/documentEventListener.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 DocumentEventListener extends LightningElement {} |
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
23 changes: 0 additions & 23 deletions
23
.../integration-tests/src/components/events/test-default-prevented/default-prevented.spec.js
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...integration-tests/src/components/events/test-default-prevented/integration/child/child.js
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...onents/events/test-default-prevented/integration/default-prevented/default-prevented.html
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...mponents/events/test-default-prevented/integration/default-prevented/default-prevented.js
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...-tests/src/components/events/test-document-event-listener/document-event-listener.spec.js
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...-document-event-listener/integration/document-event-listener/document-event-listener.html
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...st-document-event-listener/integration/document-event-listener/document-event-listener.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
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
Oops, something went wrong.