import { removeQueryParam } from './remove_query_param' ; import { createMemoryHistory , Location } from 'history' ; describe ( 'removeQueryParam' , ( ) => { it ( 'should remove query param from url' , ( ) => { const startLocation = { pathname : '/dashboard/c3a76790-3134-11ea-b024-83a7b4783735' , search : "?_a=(description:'')&_b=3" , state : null , hash : '' , } ; const history = createMemoryHistory ( ) ; history . push ( startLocation ) ; removeQueryParam ( history , '_a' ) ; expect ( history . location ) . toEqual ( expect . objectContaining ( { pathname : '/dashboard/c3a76790-3134-11ea-b024-83a7b4783735' , search : '?_b=3' , state : null , hash : '' , } ) ) ; } ) ; it ( 'should not fail if nothing to remove' , ( ) => { const startLocation = { pathname : '/dashboard/c3a76790-3134-11ea-b024-83a7b4783735' , search : "?_a=(description:'')&_b=3" , state : null , hash : '' , } ; const history = createMemoryHistory ( ) ; history . push ( startLocation ) ; removeQueryParam ( history , '_c' ) ; expect ( history . location ) . toEqual ( expect . objectContaining ( startLocation ) ) ; } ) ; it ( 'should not fail if no search' , ( ) => { const startLocation = { pathname : '/dashboard/c3a76790-3134-11ea-b024-83a7b4783735' , search : '' , state : null , hash : '' , } ; const history = createMemoryHistory ( ) ; history . push ( startLocation ) ; removeQueryParam ( history , '_c' ) ; expect ( history . location ) . toEqual ( expect . objectContaining ( startLocation ) ) ; } ) ; } ) ;