Skip to content

Commit a980d6c

Browse files
committed
Fix tests
1 parent fc0cf82 commit a980d6c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

media-placeholders/src/main/java/org/wordpress/aztec/placeholders/ImageWithCaptionAdapter.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ImageWithCaptionAdapter(
3131
private val media = mutableMapOf<String, StateFlow<ImageWithCaptionObject>>()
3232
private val scope = CoroutineScope(Dispatchers.Main)
3333
suspend override fun getHeight(attrs: AztecAttributes): Proportion {
34-
return Proportion.Ratio(attrs.getValue(HEIGHT).toFloatOrNull() ?: 0.5f)
34+
return Proportion.Ratio(0.5f)
3535
}
3636

3737
suspend override fun createView(context: Context, placeholderUuid: String, viewParamsUpdate: StateFlow<PlaceholderManager.Placeholder.ViewParams>): View {
@@ -126,22 +126,21 @@ class ImageWithCaptionAdapter(
126126
private const val ADAPTER_TYPE = "image_with_caption"
127127
private const val CAPTION_ATTRIBUTE = "caption"
128128
private const val SRC_ATTRIBUTE = "src"
129-
private const val HEIGHT = "height"
130129

131-
suspend fun insertImageWithCaption(placeholderManager: PlaceholderManager, src: String, caption: String, height: Float = 0.5f, shouldMergePlaceholders: Boolean = true) {
130+
suspend fun insertImageWithCaption(placeholderManager: PlaceholderManager, src: String, caption: String, shouldMergePlaceholders: Boolean = true) {
132131
placeholderManager.insertOrUpdateItem(ADAPTER_TYPE, {
133132
shouldMergePlaceholders
134133
}) { currentAttributes, type, placeAtStart ->
135134
if (currentAttributes == null || type != ADAPTER_TYPE) {
136-
mapOf(SRC_ATTRIBUTE to src, CAPTION_ATTRIBUTE to caption, HEIGHT to height.toString())
135+
mapOf(SRC_ATTRIBUTE to src, CAPTION_ATTRIBUTE to caption)
137136
} else {
138137
val currentCaption = currentAttributes[CAPTION_ATTRIBUTE]
139138
val newCaption = if (placeAtStart) {
140139
"$caption - $currentCaption"
141140
} else {
142141
"$currentCaption - $caption"
143142
}
144-
mapOf(SRC_ATTRIBUTE to src, CAPTION_ATTRIBUTE to newCaption, HEIGHT to height.toString())
143+
mapOf(SRC_ATTRIBUTE to src, CAPTION_ATTRIBUTE to newCaption)
145144
}
146145
}
147146
}

media-placeholders/src/test/java/org/wordpress/aztec/placeholders/PlaceholderTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class PlaceholderTest {
163163
editText.setSelection(editText.editableText.indexOf("1"))
164164
ImageWithCaptionAdapter.insertImageWithCaption(placeholderManager, "image.jpg", "Second", shouldMergePlaceholders = false)
165165

166-
Assert.assertEquals("<p>Line 1</p><placeholder uuid=\"uuid1\" type=\"image_with_caption\" src=\"image.jpg\" caption=\"Second\" /><br><placeholder src=\"image.jpg\" caption=\"First\" uuid=\"uuid1\" type=\"image_with_caption\" /><p>Line 2</p>", editText.toHtml())
166+
Assert.assertEquals("<p>Line 1</p><placeholder uuid=\"uuid2\" type=\"image_with_caption\" src=\"image.jpg\" caption=\"Second\" /><br><placeholder src=\"image.jpg\" caption=\"First\" uuid=\"uuid1\" type=\"image_with_caption\" /><p>Line 2</p>", editText.toHtml())
167167
}
168168
}
169169

@@ -191,7 +191,7 @@ class PlaceholderTest {
191191
editText.setSelection(editText.editableText.indexOf("1") + 1)
192192
ImageWithCaptionAdapter.insertImageWithCaption(placeholderManager, "image.jpg", "Second", shouldMergePlaceholders = false)
193193

194-
Assert.assertEquals("<p>Line 1</p><placeholder uuid=\"uuid1\" type=\"image_with_caption\" src=\"image.jpg\" caption=\"Second\" /><br>${placeholderWithCaption("First")}<p>Line 2</p>", editText.toHtml())
194+
Assert.assertEquals("<p>Line 1</p><placeholder uuid=\"uuid2\" type=\"image_with_caption\" src=\"image.jpg\" caption=\"Second\" /><br>${placeholderWithCaption("First")}<p>Line 2</p>", editText.toHtml())
195195
}
196196
}
197197

0 commit comments

Comments
 (0)