@@ -121,4 +121,50 @@ class MessageComposerView_Tests: StreamChatTestCase {
121
121
// Then
122
122
assertSnapshot ( matching: view, as: . image)
123
123
}
124
+
125
+ func test_composerInputView_rangeSelection( ) {
126
+ // Given
127
+ let view = ComposerTextInputView (
128
+ text: . constant( " This is a sample text " ) ,
129
+ height: . constant( 38 ) ,
130
+ selectedRangeLocation: . constant( 3 ) ,
131
+ placeholder: " Send a message " ,
132
+ editable: true
133
+ )
134
+ let inputView = InputTextView (
135
+ frame: . init( x: 16 , y: 16 , width: defaultScreenSize. width - 32 , height: 50 )
136
+ )
137
+
138
+ // When
139
+ inputView. selectedRange. location = 3
140
+ let coordinator = ComposerTextInputView . Coordinator ( textInput: view, maxMessageLength: nil )
141
+ coordinator. textViewDidChangeSelection ( inputView)
142
+
143
+ // Then
144
+ XCTAssert ( coordinator. textInput. selectedRangeLocation == 3 )
145
+ }
146
+
147
+ func test_composerInputView_textSelection( ) {
148
+ // Given
149
+ let view = ComposerTextInputView (
150
+ text: . constant( " New text " ) ,
151
+ height: . constant( 38 ) ,
152
+ selectedRangeLocation: . constant( 3 ) ,
153
+ placeholder: " Send a message " ,
154
+ editable: true
155
+ )
156
+ let inputView = InputTextView (
157
+ frame: . init( x: 16 , y: 16 , width: defaultScreenSize. width - 32 , height: 50 )
158
+ )
159
+
160
+ // When
161
+ inputView. text = " New text "
162
+ inputView. selectedRange. location = 3
163
+ let coordinator = ComposerTextInputView . Coordinator ( textInput: view, maxMessageLength: nil )
164
+ coordinator. textViewDidChange ( inputView)
165
+
166
+ // Then
167
+ XCTAssert ( coordinator. textInput. selectedRangeLocation == 3 )
168
+ XCTAssert ( coordinator. textInput. text == " New text " )
169
+ }
124
170
}
0 commit comments