package com.complycube.reactnative.config.parser import com.complycube.reactnative.config.parser.* import com.complycube.reactnative.config.helper.TestColorConverter import com.complycube.sdk.presentation.theme.UIInterfaceStyle import kotlin.test.Test import kotlin.test.assertEquals class LookAndFeelParserTest { @Test fun parsesUiInterfaceStyleAndDefaults() { val parser = LookAndFeelParser(TestColorConverter()) val look = parser.parse(mapOf( "uiInterfaceStyle" to "dark", "primaryButtonBgColor" to "#010203" )) assertEquals(UIInterfaceStyle.DARK, look.uiInterfaceStyle) assertEquals(4, look.borderRadius) assertEquals(0xFF010203L, look.primaryButtonBgColor) } @Test fun parsesAllColorFieldsAndLightMode() { val parser = LookAndFeelParser(TestColorConverter()) val data = mutableMapOf( "isDarkMode" to true, "uiInterfaceStyle" to "light", "borderRadius" to 6, "enableAnimations" to true ) val color = "#010203" val colorKeys = listOf( "primaryButtonColor", "primaryButtonBgColor", "primaryButtonTextColor", "primaryButtonBorderColor", "secondaryButtonColor", "secondaryButtonBgColor", "secondaryButtonTextColor", "secondaryButtonBorderColor", "documentSelectorColor", "documentSelectorBorderColor", "documentSelectorIconColor", "documentSelectorTitleTextColor", "documentSelectorDescriptionTextColor", "documentTypeSelectorBgColor", "documentTypeSelectorBorderColor", "documentTypeSelectorIconColor", "documentTypeSelectorTitleTextColor", "documentTypeSelectorDescriptionTextColor", "infoPopupColor", "infoPopupIconColor", "infoPopupTitleTextColor", "infoPopupDescriptionTextColor", "infoPanelColor", "infoPanelBgColor", "infoPanelIconColor", "infoPanelTitleTextColor", "infoPanelDescriptionTextColor", "errorPopupColor", "errorPopupIconColor", "errorPopupTitleTextColor", "errorPopupDescriptionTextColor", "errorPanelColor", "errorPanelBgColor", "errorPanelIconColor", "errorPanelTitleTextColor", "errorPanelDescriptionTextColor", "cameraButtonColor", "bodyTextColor", "headingTextColor", "subheadingTextColor", "backgroundColor", "backgroundContentColor", "backgroundContentContrastColor", "backgroundDividerColor", "editTextColor" ) colorKeys.forEach { key -> data[key] = color } val look = parser.parse(data) assertEquals(UIInterfaceStyle.LIGHT, look.uiInterfaceStyle) assertEquals(6, look.borderRadius) assertEquals(0xFF010203L, look.primaryButtonBgColor) assertEquals(0xFF010203L, look.documentTypeSelectorBgColor) assertEquals(0xFF010203L, look.backgroundDividerColor) } @Test fun unknownInterfaceStyleFallsBackToInherited() { val parser = LookAndFeelParser(TestColorConverter()) val look = parser.parse(mapOf("uiInterfaceStyle" to "auto")) assertEquals(UIInterfaceStyle.INHERITED, look.uiInterfaceStyle) } }