mirror of
https://github.com/lana-k/sqliteviz.git
synced 2026-02-04 15:38:55 +08:00
tests
This commit is contained in:
20
tests/testUtils.js
Normal file
20
tests/testUtils.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export function waitCondition(condition, timeoutMs = 5000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (condition()) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const start = new Date().getTime()
|
||||
const interval = setInterval(() => {
|
||||
if (condition()) {
|
||||
clearInterval(interval)
|
||||
resolve()
|
||||
} else {
|
||||
if (new Date().getTime() - start > timeoutMs) {
|
||||
clearInterval(interval)
|
||||
reject()
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user