mirror of
https://github.com/documize/community.git
synced 2025-08-09 07:25:23 +02:00
Add wait-to-appear helper
This commit is contained in:
parent
3f0d98a5b0
commit
43eb62f08e
1 changed files with 22 additions and 0 deletions
22
app/tests/helpers/wait-to-appear.js
Normal file
22
app/tests/helpers/wait-to-appear.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
function isVisible(selector) {
|
||||||
|
return $(selector).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkVisibility(selector, interval, resolve, visibility) {
|
||||||
|
if (isVisible(selector) === visibility) {
|
||||||
|
resolve($(selector));
|
||||||
|
} else {
|
||||||
|
console.log('waiting for visibility');
|
||||||
|
Ember.run.later(null, function() {
|
||||||
|
checkVisibility(selector, interval, resolve, visibility);
|
||||||
|
}, interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Ember.Test.registerAsyncHelper('waitToAppear', function(app, selector, interval = 200) {
|
||||||
|
return new Ember.RSVP.Promise(function(resolve) {
|
||||||
|
checkVisibility(selector, interval, resolve, true);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue