status-desktop/storybook/qmlTests/tests/tst_BannerCard.qml
Alex Jbanca 5e6db4d2ff feat(WalletFirst): Creating the wallet banner UI component
Banner items are created as per design.
Banner items support customizable close button.
Banner items have hove state as per design.
Banner items are added to storybook with all possible configurations.
Banner items have a close animation including fade-out and the remaining item occupy the empty space.
QML tests are added.
2024-11-22 12:47:18 +02:00

77 lines
2.0 KiB
QML

import QtQuick 2.15
import QtTest 1.15
import AppLayouts.Wallet.controls 1.0
Item {
id: root
width: 600
height: 400
Component {
id: bannerCardComponent
BannerCard {}
}
TestCase {
id: bannerCardTest
when: windowShown
property BannerCard componentUnderTest
function init() {
componentUnderTest = createTemporaryObject(bannerCardComponent, root)
}
function test_empty() {
compare(componentUnderTest.image, "")
compare(componentUnderTest.title, "")
compare(componentUnderTest.subTitle, "")
compare(componentUnderTest.closeEnabled, true)
}
function test_geometry() {
verify(componentUnderTest.height > 0)
verify(componentUnderTest.width > 0)
}
function test_hoverState() {
compare(componentUnderTest.hovered, false)
mouseMove(componentUnderTest)
compare(componentUnderTest.hovered, true)
const closeButton = findChild(componentUnderTest, "bannerCard_closeButton")
verify(!!closeButton)
verify(closeButton.visible)
verify(closeButton.width > 0)
verify(closeButton.height > 0)
mouseMove(closeButton, closeButton.width / 2, closeButton.height / 2)
compare(componentUnderTest.hovered, true)
}
function test_click() {
let clicked = false
componentUnderTest.clicked.connect(() => {
clicked = true
})
mouseClick(componentUnderTest)
compare(clicked, true)
clicked = false
const closeButton = findChild(componentUnderTest, "bannerCard_closeButton")
let closed = false
componentUnderTest.close.connect(() => {
closed = true
})
mouseClick(closeButton)
compare(closed, true)
compare(clicked, false)
}
}
}