I'm trying to test the code that sets a page title depending on the activated route in a component.
// Title Map
pageTitleMap = {
page1: "Page 1",
page2: "Page 2"
}
// Method to be tested
setPageTitle() {
this._Activatedroute.url.subscribe((urlPath) => {
const parentPath = urlPath[0].path;
this.pageTitle = `${this.pageTitleMap[parentPath]} - TITLE`;
})
}
it('should set page title depending on URL path', () => {
// How do I test the code in setPageTitle?
});