From 269e11a246f31879fc68e108e9c3c36f42b45f35 Mon Sep 17 00:00:00 2001 From: "B.Melnik" Date: Mon, 25 Oct 2021 13:12:13 +0300 Subject: [PATCH] Add tests for statusSwitch --- tests.qrc | 1 + tst_status_switch.qml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tst_status_switch.qml diff --git a/tests.qrc b/tests.qrc index 8ed3f26..794f615 100644 --- a/tests.qrc +++ b/tests.qrc @@ -13,5 +13,6 @@ tst_chatinfotoolbar.qml tst_statuslistitem.qml tst_statusexpandableitem.qml + tst_status_switch.qml diff --git a/tst_status_switch.qml b/tst_status_switch.qml new file mode 100644 index 0000000..4dc3855 --- /dev/null +++ b/tst_status_switch.qml @@ -0,0 +1,34 @@ +import QtQuick 2.14 +import QtTest 1.14 + +import StatusQ.Controls 0.1 + +import "base" + +WindowTestCase { + name: "StatusSwitch test" + + SignalSpy { + id: clickSpy + target: statusSwitch + signalName: "clicked" + } + + StatusSwitch { + id: statusSwitch + parent: windowContent + text: "unit test" + } + + function test_clickOnSwitch() { + verify(clickSpy.valid, "Signal clicked not valid") + verify(!statusSwitch.checked, "Switch is checked on init") + compare(statusSwitch.text, "unit test", "Text property is not working") + + compare(clickSpy.count, 0, "Signal spy is not cleared") + mouseClick(statusSwitch, 1, 1, Qt.LeftButton) + compare(clickSpy.count, 1, "Signal is not emited") + + verify(statusSwitch.checked, "Switch is not checked") + } +}