mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-01 17:27:53 +00:00
Storybook: TestUtils singleton added
This commit is contained in:
parent
8c2d2115b0
commit
bb2eeaa79d
42
storybook/src/Storybook/TestUtils.qml
Normal file
42
storybook/src/Storybook/TestUtils.qml
Normal file
@ -0,0 +1,42 @@
|
||||
pragma Singleton
|
||||
|
||||
import QtQuick 2.15
|
||||
|
||||
import QtQml 2.15
|
||||
|
||||
QtObject {
|
||||
function findTextItem(root, text) {
|
||||
for (let i = 0; i < root.children.length; i++) {
|
||||
const c = root.children[i]
|
||||
|
||||
if (c instanceof Text && c.text === text)
|
||||
return c
|
||||
|
||||
const sub = findTextItem(c, text)
|
||||
|
||||
if (sub)
|
||||
return sub
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function findByType(root, type) {
|
||||
const children = []
|
||||
|
||||
for (let i = 0; i < root.children.length; i++)
|
||||
children.push(root.children[i])
|
||||
|
||||
while (children.length > 0) {
|
||||
const c = children.shift()
|
||||
|
||||
if (c instanceof type)
|
||||
return c
|
||||
|
||||
for (let i = 0; i < c.children.length; i++)
|
||||
children.push(c.children[i])
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
@ -33,3 +33,4 @@ TestRunnerControls 1.0 TestRunnerControls.qml
|
||||
singleton FigmaUtils 1.0 FigmaUtils.qml
|
||||
singleton InspectionUtils 1.0 InspectionUtils.qml
|
||||
singleton StorybookUtils 1.0 StorybookUtils.qml
|
||||
singleton TestUtils 1.0 TestUtils.qml
|
||||
|
Loading…
x
Reference in New Issue
Block a user