-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Snapshot test for RedwoodView (#2331)
* Snapshot test for RedwoodView Closes: #1859 * Actually exercise the interesting bit from the bug report * Track rebase
- Loading branch information
1 parent
fa38c71
commit 616e91c
Showing
19 changed files
with
856 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import static app.cash.redwood.buildsupport.TargetGroup.ToolkitAllWithoutAndroid | ||
|
||
redwoodBuild { | ||
targets(ToolkitAllWithoutAndroid) | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
api projects.redwoodLayoutApi | ||
api projects.redwoodLayoutModifiers | ||
api projects.redwoodLayoutWidget | ||
api projects.redwoodRuntime | ||
api projects.redwoodSnapshotTesting | ||
api projects.redwoodTesting | ||
api projects.redwoodWidget | ||
api projects.redwoodYoga | ||
api libs.kotlin.test | ||
} | ||
} | ||
jvmMain { | ||
dependencies { | ||
// The kotlin.test library provides JVM variants for multiple testing frameworks. When used | ||
// as a test dependency this selection is transparent. But since we are publishing a library | ||
// we need to select one ourselves at compilation time. | ||
api libs.kotlin.test.junit | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...dget-shared-test/src/commonMain/kotlin/app/cash/redwood/widget/AbstractRedwoodViewTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* 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 app.cash.redwood.widget | ||
|
||
import app.cash.redwood.snapshot.testing.Snapshotter | ||
import app.cash.redwood.snapshot.testing.TestWidgetFactory | ||
import app.cash.redwood.snapshot.testing.text | ||
import kotlin.test.Test | ||
|
||
abstract class AbstractRedwoodViewTest<W : Any, R : RedwoodView<W>> { | ||
|
||
abstract val widgetFactory: TestWidgetFactory<W> | ||
|
||
abstract fun redwoodView(): R | ||
|
||
abstract fun snapshotter(redwoodView: R): Snapshotter | ||
|
||
/** | ||
* This test uses a string that wraps to confirm the root view's dimensions aren't unbounded. | ||
* https://github.com/cashapp/redwood/issues/2128 | ||
*/ | ||
@Test | ||
fun testSingleChildElement() { | ||
val redwoodView = redwoodView() | ||
redwoodView.children.insert(0, widgetFactory.text("Hello ".repeat(50))) | ||
snapshotter(redwoodView).snapshot() | ||
} | ||
} |
Oops, something went wrong.