Skip to content

Commit

Permalink
Merge pull request #806 from splendo/792-fix-button-style-crash
Browse files Browse the repository at this point in the history
Fixed crash where buttonstyle could still not be mocked
  • Loading branch information
Daeda88 authored Sep 4, 2024
2 parents d6d007f + e10246d commit 63eed61
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
1 change: 1 addition & 0 deletions resources/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ kaluga {
}
test {
implementation(project(":test-utils-base", ""))
implementation(project(":test-utils-resources", ""))
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions resources/src/commonMain/kotlin/stylable/KalugaButtonStyle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ sealed interface KalugaButtonStyle<StateStyle : ButtonStateStyle> {
)
}

internal val hiddenTextStyle = textOnly {
textSize = 0.0f
defaultStyle {
textColor = DefaultColors.clear
internal val hiddenTextStyle by lazy {
textOnly {
textSize = 0.0f
defaultStyle {
textColor = DefaultColors.clear
}
}
}
}
Expand Down
37 changes: 37 additions & 0 deletions resources/src/commonTest/kotlin/ButtonTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2024 Splendo Consulting B.V. The Netherlands
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.splendo.kaluga.resources

import com.splendo.kaluga.resources.stylable.KalugaButtonStyle
import com.splendo.kaluga.resources.view.KalugaButton
import com.splendo.kaluga.test.base.BaseTest
import com.splendo.kaluga.test.resources.mockFont
import kotlin.test.Test

class ButtonTest : BaseTest() {

@Test
fun buttonStyleCanBeMocked() {
val button = KalugaButton.Plain(
"Test",
KalugaButtonStyle.withImageAndText {
font = mockFont()
},
) {}
}
}

0 comments on commit 63eed61

Please sign in to comment.