@@ -23,7 +23,7 @@ import {MatDialog, MatDialogModule} from '@angular/material/dialog';
2323import { MatSnackBar } from '@angular/material/snack-bar' ;
2424import { By } from '@angular/platform-browser' ;
2525import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
26- import { ActivatedRoute , NavigationEnd , Router } from '@angular/router' ;
26+ import { ActivatedRoute , NavigationEnd , Router , UrlTree } from '@angular/router' ;
2727// 1p-ONLY-IMPORTS: import {beforeEach, describe, expect, it}
2828import { BehaviorSubject , NEVER , of , ReplaySubject , Subject , throwError } from 'rxjs' ;
2929
@@ -935,32 +935,22 @@ describe('ChatComponent', () => {
935935 } ) ;
936936
937937 it (
938- 'should clear "q" query param when message is sent' ,
939- fakeAsync ( ( ) => {
940- mockAgentService . setApp ( '' ) ; // Initially no app
941- mockActivatedRoute . snapshot !
942- . queryParams = { [ INITIAL_USER_INPUT_QUERY_PARAM ] : 'hello' } ;
943- mockActivatedRoute . queryParams =
944- of ( { [ INITIAL_USER_INPUT_QUERY_PARAM ] : 'hello' } ) ;
945- const urlTree = {
946- queryParams : { [ INITIAL_USER_INPUT_QUERY_PARAM ] : 'hello' } ,
947- } ;
938+ 'should clear "q" query param when message is sent' , fakeAsync ( ( ) => {
939+ const urlTree = new UrlTree ( ) ;
940+ urlTree . queryParams = { [ INITIAL_USER_INPUT_QUERY_PARAM ] : 'hello' } ;
948941 mockRouter . parseUrl . and . returnValue ( urlTree as any ) ;
949942 mockLocation . path . and . returnValue ( '/?q=hello' ) ;
943+
950944 fixture = TestBed . createComponent ( ChatComponent ) ;
951945 component = fixture . componentInstance ;
952- fixture . detectChanges ( ) ;
953- mockAgentService . setApp ( TEST_APP_1_NAME ) ;
954- tick ( ) ;
955-
946+ component . userInput = 'hello' ;
956947 component . sendMessage ( new KeyboardEvent ( 'keydown' , { key : 'Enter' } ) ) ;
957948 tick ( ) ;
958949
959950 expect ( mockLocation . path ) . toHaveBeenCalled ( ) ;
960951 expect ( mockRouter . parseUrl ) . toHaveBeenCalledWith ( '/?q=hello' ) ;
961- expect ( urlTree . queryParams ) . toEqual ( { } as any ) ; // q param should be
962- // deleted.
963- expect ( mockRouter . navigateByUrl ) . toHaveBeenCalledWith ( urlTree as any ) ;
952+ // The query param should be removed from the URL.
953+ expect ( mockLocation . replaceState ) . toHaveBeenCalledWith ( '/' ) ;
964954 } ) ) ;
965955
966956 describe ( 'when event contains multiple text parts' , ( ) => {
0 commit comments