Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Angular] Fix console warnings when running main.component.spec.ts #25762

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { waitForAsync, ComponentFixture, TestBed, fakeAsync, tick } from '@angul
import { Router, TitleStrategy } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { DOCUMENT } from '@angular/common';
import { Component } from '@angular/core';
import { Component, NgZone } from '@angular/core';
import { of } from 'rxjs';
<%_ if (enableTranslation) { _%>
import { TranslateModule, TranslateService, LangChangeEvent } from '@ngx-translate/core';
Expand All @@ -47,6 +47,7 @@ describe('MainComponent', () => {
<%_ } _%>
<%_ } _%>
let mockAccountService: AccountService;
let ngZone: NgZone;
const routerState: any = { snapshot: { root: { data: {} } } };
let router: Router;
let document: Document;
Expand Down Expand Up @@ -87,6 +88,7 @@ describe('MainComponent', () => {
mockAccountService = TestBed.inject(AccountService);
mockAccountService.identity = jest.fn(() => of(null));
mockAccountService.getAuthenticationState = jest.fn(() => of(null));
ngZone = TestBed.inject(NgZone);
router = TestBed.inject(Router);
document = TestBed.inject(DOCUMENT);
});
Expand All @@ -112,7 +114,7 @@ describe('MainComponent', () => {
describe('navigation end', () => {
it('should set page title to default title if pageTitle is missing on routes', fakeAsync(() => {
// WHEN
router.navigateByUrl('');
ngZone.run(() => router.navigateByUrl(''));
tick();

// THEN
Expand All @@ -124,7 +126,7 @@ describe('MainComponent', () => {
router.resetConfig([{ path: '', title: parentRoutePageTitle, component: BlankComponent }]);

// WHEN
router.navigateByUrl('');
ngZone.run(() => router.navigateByUrl(''));
tick();

// THEN
Expand All @@ -144,7 +146,7 @@ describe('MainComponent', () => {
]);

// WHEN
router.navigateByUrl('home');
ngZone.run(() => router.navigateByUrl('home'));
tick();

// THEN
Expand All @@ -164,22 +166,15 @@ describe('MainComponent', () => {
]);

// WHEN
router.navigateByUrl('home');
ngZone.run(() => router.navigateByUrl('home'));
tick();

// THEN
expect(document.title).toBe(parentRoutePageTitle<% if (enableTranslation) { %> + ' translated'<% } %>);
}));
});








<%_ if (enableTranslation) { _%>

describe('language change', () => {
it('should set page title to default title if pageTitle is missing on routes', () => {
// WHEN
Expand All @@ -195,7 +190,7 @@ describe('MainComponent', () => {
router.resetConfig([{ path: '', title: parentRoutePageTitle, component: BlankComponent }]);

// WHEN
router.navigateByUrl('');
ngZone.run(() => router.navigateByUrl(''));
tick();

// THEN
Expand Down Expand Up @@ -224,7 +219,7 @@ describe('MainComponent', () => {
]);

// WHEN
router.navigateByUrl('home');
ngZone.run(() => router.navigateByUrl('home'));
tick();

// THEN
Expand Down Expand Up @@ -253,7 +248,7 @@ describe('MainComponent', () => {
]);

// WHEN
router.navigateByUrl('home');
ngZone.run(() => router.navigateByUrl('home'));
tick();

// THEN
Expand Down
Loading