Commit cb131ed7 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(utils.spec.qml): add a test on `setTimeout`

parent e30574e0
...@@ -97,7 +97,7 @@ function setTimeout (delay, cb) { ...@@ -97,7 +97,7 @@ function setTimeout (delay, cb) {
} }
function clearTimeout (timer) { function clearTimeout (timer) {
timer.destroy() // Not necessary: `timer.stop()` timer.destroy() // Unnecessary call: `timer.stop()`
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -5,7 +5,11 @@ import QtTest 1.1 ...@@ -5,7 +5,11 @@ import QtTest 1.1
// when tests are executed. // when tests are executed.
import './utils.js' as Utils import './utils.js' as Utils
// ===================================================================
TestCase { TestCase {
id: testCase
name: 'UtilsTests' name: 'UtilsTests'
function test_snakeToCamel_data () { function test_snakeToCamel_data () {
...@@ -20,4 +24,38 @@ TestCase { ...@@ -20,4 +24,38 @@ TestCase {
function test_snakeToCamel (data) { function test_snakeToCamel (data) {
compare(Utils.snakeToCamel(data.input), data.output) compare(Utils.snakeToCamel(data.input), data.output)
} }
function test_setTimeoutWithoutParent () {
try {
Utils.setTimeout(0, function () {
fail('`setTimeout` was called without parent.')
})
} catch (e) {
compare(e, 'Error: Qt.createQmlObject(): Missing parent object')
}
}
function test_setTimeout_data () {
return [
{ time: 0 },
{ time: 100 }
]
}
function test_setTimeout (data) {
var failed = true
Utils.setTimeout.call(testCase, data.time, function () {
failed = false
})
if (!failed) {
fail('`setTimeout` callback was called before `wait`')
}
wait(200)
if (failed) {
fail('`setTimeout` failed because callback it was not called in due course')
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment