@@ -349,6 +349,69 @@ class MessageComposerViewModel_Tests: XCTestCase {
349
349
XCTAssert ( isDMChannel == true )
350
350
}
351
351
352
+ func test_messageComposerVM_settingComposerCommand( ) {
353
+ // Given
354
+ let viewModel = makeComposerViewModel ( )
355
+
356
+ // When
357
+ viewModel. text = " /giphy "
358
+
359
+ // Then
360
+ XCTAssert ( viewModel. composerCommand != nil )
361
+ XCTAssert ( viewModel. composerCommand? . id == " /giphy " )
362
+ }
363
+
364
+ func test_messageComposerVM_instantCommandsShown( ) {
365
+ // Given
366
+ let viewModel = makeComposerViewModel ( )
367
+
368
+ // When
369
+ viewModel. pickerTypeState = . expanded( . giphy)
370
+
371
+ // Then
372
+ XCTAssert ( viewModel. composerCommand != nil )
373
+ XCTAssert ( viewModel. composerCommand? . id == " instantCommands " )
374
+ }
375
+
376
+ func test_messageComposerVM_giphySendButtonEnabled( ) {
377
+ // Given
378
+ let viewModel = makeComposerViewModel ( )
379
+ let command = ComposerCommand (
380
+ id: " /giphy " ,
381
+ typingSuggestion: TypingSuggestion (
382
+ text: " /giphy " ,
383
+ locationRange: NSRange ( location: 1 , length: 5 )
384
+ ) ,
385
+ displayInfo: CommandDisplayInfo (
386
+ displayName: " Giphy " ,
387
+ icon: UIImage ( systemName: " xmark " ) !,
388
+ format: " /giphy [text] " ,
389
+ isInstant: true
390
+ )
391
+ )
392
+
393
+ // When
394
+ viewModel. composerCommand = command
395
+ let initialSendButtonState = viewModel. sendButtonEnabled
396
+ viewModel. text = " hey "
397
+ let finalSendButtonState = viewModel. sendButtonEnabled
398
+
399
+ // Then
400
+ XCTAssert ( initialSendButtonState == false )
401
+ XCTAssert ( finalSendButtonState == true )
402
+ }
403
+
404
+ func test_messageComposerVM_suggestionsShown( ) {
405
+ // Given
406
+ let viewModel = makeComposerViewModel ( )
407
+
408
+ // When
409
+ viewModel. pickerTypeState = . expanded( . giphy)
410
+
411
+ // Then
412
+ XCTAssert ( !viewModel. suggestions. isEmpty)
413
+ }
414
+
352
415
// MARK: - private
353
416
354
417
private func makeComposerViewModel( ) -> MessageComposerViewModel {
0 commit comments