-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test helpers for Ember 4.0 (#929)
- Loading branch information
1 parent
448dc31
commit f0ab3dc
Showing
29 changed files
with
3,081 additions
and
1,372 deletions.
There are no files selected for viewing
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
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
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,51 @@ | ||
import { settled, triggerEvent } from '@ember/test-helpers'; | ||
import { Promise } from 'rsvp'; | ||
|
||
/** | ||
Ported from https://github.com/emberjs/ember-test-helpers/blob/ea591697a98975737647b4c0043477cc6796569b/addon-test-support/%40ember/test-helpers/dom/scroll-to.ts | ||
This can be dropped in favor of the test-helpers provided scrollTo after | ||
Ember 2.18 support is dropped and test-helpers is upgraded. | ||
*/ | ||
|
||
/** | ||
Scrolls DOM element or selector to the given coordinates. | ||
@public | ||
@param {string|HTMLElement} target the element or selector to trigger scroll on | ||
@param {Number} x x-coordinate | ||
@param {Number} y y-coordinate | ||
@return {Promise<void>} resolves when settled | ||
@example | ||
<caption> | ||
Scroll DOM element to specific coordinates | ||
</caption> | ||
scrollTo('#my-long-div', 0, 0); // scroll to top | ||
scrollTo('#my-long-div', 0, 100); // scroll down | ||
*/ | ||
export default function scrollTo(target, x, y) { | ||
return Promise.resolve().then(() => { | ||
if (!target) { | ||
throw new Error('Must pass an element or selector to `scrollTo`.'); | ||
} | ||
|
||
if (x === undefined || y === undefined) { | ||
throw new Error('Must pass both x and y coordinates to `scrollTo`.'); | ||
} | ||
|
||
let element = target instanceof Node ? target : document.querySelector(target); | ||
if (!element) { | ||
throw new Error(`Element not found when calling \`scrollTo('${target}')\`.`); | ||
} | ||
|
||
element.scrollTop = y; | ||
element.scrollLeft = x; | ||
|
||
triggerEvent(element, 'scroll'); | ||
|
||
return settled(); | ||
}); | ||
} |
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,33 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<title>Dummy Tests</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content="" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
|
||
{{content-for "head"}} | ||
{{content-for "test-head"}} | ||
{{content-for "head"}} {{content-for "test-head"}} | ||
|
||
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css"> | ||
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css"> | ||
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css"> | ||
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css" /> | ||
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css" /> | ||
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css" /> | ||
|
||
{{content-for "head-footer"}} | ||
{{content-for "test-head-footer"}} | ||
{{content-for "head-footer"}} {{content-for "test-head-footer"}} | ||
</head> | ||
<body> | ||
{{content-for "body"}} | ||
{{content-for "test-body"}} | ||
{{content-for "body"}} {{content-for "test-body"}} | ||
|
||
<!-- | ||
Normally for modern Ember you find the qunit | ||
boilerplate here. To maintain compatibility with | ||
a broad range of Ember versions, instead the | ||
boilerplate is added dynamically in test-heler.js | ||
After 2.18 support is dropped, the boilerplate can | ||
be moved back here. | ||
--> | ||
|
||
<script src="/testem.js" integrity=""></script> | ||
<script src="{{rootURL}}assets/vendor.js"></script> | ||
<script src="{{rootURL}}assets/test-support.js"></script> | ||
<script src="{{rootURL}}assets/dummy.js"></script> | ||
<script src="{{rootURL}}assets/tests.js"></script> | ||
|
||
{{content-for "body-footer"}} | ||
{{content-for "test-body-footer"}} | ||
{{content-for "body-footer"}} {{content-for "test-body-footer"}} | ||
</body> | ||
</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
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.