Ignore "@instance..." part of username when computing status length (#3392)
* Move compose.* tests to own namespace
* Ignore "@instance..." part of username when computing status length
In a status with a mention ("@foo@example.org") only the "@foo" part should
be included in the calculated status length. It wasn't, so the app was
prevening people from posting statuses that should have been allowed.
Fix this.
- Lift the length calculation code in to a separate static function (easier
and faster to test)
- Add a `MentionSpan` type, to reuse existing code for detecting mentions
- Fix a bug in `FakeSpannable.getSpans()` (it was returning the outer type,
not the wrapped inner span)
- Add additional fast tests
The tests made sense under the `components.compose.ComposeActivity` package,
so I also created that and moved the existing ComposeActivity tests there.
Fixes https://github.com/tuskyapp/Tusky/issues/3339
* Static import assertEquals
This commit is contained in:
parent
f309c7750f
commit
6dfdaec425
8 changed files with 158 additions and 23 deletions
|
|
@ -136,7 +136,7 @@ class SpanUtilsTest {
|
|||
}
|
||||
|
||||
override fun <T : Any> getSpans(start: Int, end: Int, type: Class<T>): Array<T> {
|
||||
return spans.filter { it.start >= start && it.end <= end && type.isInstance(it) }
|
||||
return spans.filter { it.start >= start && it.end <= end && type.isInstance(it.span) }
|
||||
.map { it.span }
|
||||
.toTypedArray() as Array<T>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue