Location
defines a structure, including a property called "search", as shown below:
interface Location {
...
search: string;
...
}
An example service is presented here:
export class MyService {
constructor(private readonly location: Location) {}
public myMethod(search: string): void {
this.location.search = search;
}
}
Additionally, a test scenario is described:
describe('MyService', () => {
it('should set search on location', () => {
const location = mock<Location>();
const myService = new MyService(instance(location));
const someSearch = 'a=1';
myService.myMethod(someSearch);
// To confirm that location.search has been updated
});
});
The question arises: How can one validate that the setter for search
has successfully received and applied the correct value?