Changeset View
Changeset View
Standalone View
Standalone View
src/tests/quick-tests/tst_RoomStickerPackItemDelegate.qml
| /* | /* | ||||
| * This file is part of kazv. | * This file is part of kazv. | ||||
| * SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe> | * SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe> | ||||
| * SPDX-License-Identifier: AGPL-3.0-or-later | * SPDX-License-Identifier: AGPL-3.0-or-later | ||||
| */ | */ | ||||
| import QtQuick | import QtQuick | ||||
| import QtQuick.Layouts | import QtQuick.Layouts | ||||
| import QtTest | import QtTest | ||||
| import moe.kazv.mxc.kazv as MK | import moe.kazv.mxc.kazv as MK | ||||
| import org.kde.kirigami as Kirigami | import org.kde.kirigami as Kirigami | ||||
| import '../../contents/ui/room-settings' as KazvRS | import '../../contents/ui/room-settings' as KazvRS | ||||
| import 'test-helpers.js' as Helpers | import 'test-helpers.js' as JsHelpers | ||||
| import 'test-helpers' as TestHelpers | import 'test-helpers' as QmlHelpers | ||||
| Item { | QmlHelpers.TestItem { | ||||
| id: item | id: item | ||||
| width: 800 | |||||
| height: 600 | |||||
| property var mockHelper: TestHelpers.MockHelper {} | |||||
| property var matrixSdk: TestHelpers.MatrixSdkMock { | |||||
| property var sendAccountData: mockHelper.promise() | |||||
| } | |||||
| KazvRS.RoomStickerPackItemDelegate { | KazvRS.RoomStickerPackItemDelegate { | ||||
| id: packItem | id: packItem | ||||
| } | } | ||||
| TestCase { | TestCase { | ||||
| id: roomStickerPackItemDelegateTest | id: roomStickerPackItemDelegateTest | ||||
| name: 'RoomStickerPackItemDelegateTest' | name: 'RoomStickerPackItemDelegateTest' | ||||
| when: windowShown | when: windowShown | ||||
| Show All 14 Lines | function init() { | ||||
| }; | }; | ||||
| } | } | ||||
| function test_usePack() { | function test_usePack() { | ||||
| const usePackAction = findChild(packItem, 'usePackAction'); | const usePackAction = findChild(packItem, 'usePackAction'); | ||||
| verify(!usePackAction.checked); | verify(!usePackAction.checked); | ||||
| usePackAction.trigger(); | usePackAction.trigger(); | ||||
| tryVerify(() => matrixSdk.sendAccountData.calledTimes() === 1); | tryVerify(() => matrixSdk.sendAccountData.calledTimes() === 1); | ||||
| verify(Helpers.deepEqual( | verify(JsHelpers.deepEqual( | ||||
| matrixSdk.sendAccountData.lastArgs()[1], | matrixSdk.sendAccountData.lastArgs()[1], | ||||
| { | { | ||||
| rooms: { | rooms: { | ||||
| '!foo:example.com': { | '!foo:example.com': { | ||||
| 'some-pack': {}, | 'some-pack': {}, | ||||
| }, | }, | ||||
| }, | }, | ||||
| }, | }, | ||||
| Show All 10 Lines | function test_disusePack() { | ||||
| }, | }, | ||||
| }, | }, | ||||
| }; | }; | ||||
| const usePackAction = findChild(packItem, 'usePackAction'); | const usePackAction = findChild(packItem, 'usePackAction'); | ||||
| verify(usePackAction.checked); | verify(usePackAction.checked); | ||||
| usePackAction.trigger(); | usePackAction.trigger(); | ||||
| tryVerify(() => matrixSdk.sendAccountData.calledTimes() === 1); | tryVerify(() => matrixSdk.sendAccountData.calledTimes() === 1); | ||||
| verify(Helpers.deepEqual( | verify(JsHelpers.deepEqual( | ||||
| matrixSdk.sendAccountData.lastArgs()[1], | matrixSdk.sendAccountData.lastArgs()[1], | ||||
| { | { | ||||
| rooms: { | rooms: { | ||||
| '!foo:example.com': { | '!foo:example.com': { | ||||
| }, | }, | ||||
| }, | }, | ||||
| }, | }, | ||||
| )); | )); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||