From ac1c3ad4404799fcda340b9ec70fd047ba440522 Mon Sep 17 00:00:00 2001 From: Siddharth Agarwal Date: Thu, 12 Sep 2024 14:29:13 +0530 Subject: [PATCH] Add unit test to check clear all button logic --- .../component/OrgBottomSheetTest.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/OrgBottomSheetTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/OrgBottomSheetTest.kt index cd382796d..09d5312b1 100644 --- a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/OrgBottomSheetTest.kt +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/OrgBottomSheetTest.kt @@ -123,4 +123,38 @@ class OrgBottomSheetTest { rule.onNodeWithTag("ORG_TREE_ITEM_CHECKBOX_Item 1").assertExists() rule.onNodeWithTag("ORG_TREE_ITEM_CHECKBOX_Item 2").assertDoesNotExist() } + + @Test + fun shouldHideClearButtonWhenOnClearAllMethodIsNotProvided() { + rule.setContent { + OrgBottomSheet( + orgTreeItems = listOf( + OrgTreeItem( + uid = "1", + label = "Item 1", + canBeSelected = true, + ), + OrgTreeItem( + uid = "2", + label = "Item 2", + canBeSelected = false, + ), + ), + onDismiss = { + // no-op + }, + onItemClick = { + // no-op + }, + onItemSelected = { _, _ -> + // no-op + }, + onDone = { + // no-op + }, + ) + } + + rule.onNodeWithTag("CLEAR_ALL_BUTTON").assertDoesNotExist() + } }