Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4114239
utils.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
utils.js
View Options
'use strict'
;
/**
* Waits until the specified selector to no longer match any elements in the QUnit test fixture.
*
* @param {string} selector The JQuery selector to check
* @return {Promise}
*/
function
waitUntilElementDisappears
(
selector
)
{
return
waitUntilElementCount
(
selector
,
0
);
}
/**
* Waits until the specified selector appears in the QUnit test fixture.
*
* @param {string} selector The JQuery selector to check
* @return {Promise}
*/
function
waitUntilElementAppears
(
selector
)
{
return
waitUntilElementCount
(
selector
,
1
);
}
/**
* Waits until the specified selector matches the specified count of elements in
* the QUnit test fixture.
*
* @param {string} selector The JQuery selector to check
* @param {number} count The number of elements to wait for
* @return {Promise}
*/
function
waitUntilElementCount
(
selector
,
count
)
{
// eslint-disable-next-line no-jquery/no-global-selector
const
$qunitFixture
=
$
(
'#qunit-fixture'
);
return
new
Promise
(
(
resolve
)
=>
{
// Check every 10ms if the class matches any element in the QUnit test fixture.
// If the class is no longer present, then resolve is called.
// If this condition is not met ever, then QUnit will time the test out after 6s.
function
runCheck
()
{
setTimeout
(
()
=>
{
if
(
$
(
selector
,
$qunitFixture
).
length
===
count
)
{
return
resolve
();
}
runCheck
();
},
10
);
}
runCheck
();
}
);
}
module
.
exports
=
{
waitUntilElementDisappears
:
waitUntilElementDisappears
,
waitUntilElementAppears
:
waitUntilElementAppears
,
waitUntilElementCount
:
waitUntilElementCount
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 18, 23:57 (2 d, 12 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f6/92/bb9cad392346be7aa92d614257c8
Default Alt Text
utils.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment