From 3996880ab7585ee71530081ea2fa834033f7871a Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Mon, 26 Oct 2020 16:54:14 +0100 Subject: [PATCH] MOBILE-3320 tests: Fix tests --- src/app/app.component.test.ts | 10 ++++++++-- src/app/components/tests/icon.test.ts | 2 +- src/app/core/login/tests/init.page.test.ts | 8 +++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/app.component.test.ts b/src/app/app.component.test.ts index e2c1c1958..72baacfd2 100644 --- a/src/app/app.component.test.ts +++ b/src/app/app.component.test.ts @@ -12,22 +12,27 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { NavController } from '@ionic/angular'; + import { AppComponent } from '@app/app.component'; import { CoreEvents } from '@singletons/events'; import { CoreLangProvider } from '@services/lang'; import { mock, renderComponent, RenderConfig } from '@/tests/utils'; -describe('App component', () => { +describe('AppComponent', () => { let langProvider: CoreLangProvider; + let navController: NavController; let config: Partial; beforeEach(() => { langProvider = mock(['clearCustomStrings']); + navController = mock(['navigateRoot']); config = { providers: [ { provide: CoreLangProvider, useValue: langProvider }, + { provide: NavController, useValue: navController }, ], }; }); @@ -39,13 +44,14 @@ describe('App component', () => { expect(fixture.nativeElement.querySelector('ion-router-outlet')).toBeTruthy(); }); - it('clears custom strings on logout', async () => { + it('cleans up on logout', async () => { const fixture = await renderComponent(AppComponent, config); fixture.componentInstance.ngOnInit(); CoreEvents.trigger(CoreEvents.LOGOUT); expect(langProvider.clearCustomStrings).toHaveBeenCalled(); + expect(navController.navigateRoot).toHaveBeenCalledWith('/login/sites'); }); }); diff --git a/src/app/components/tests/icon.test.ts b/src/app/components/tests/icon.test.ts index a79fcbc9b..e7157feda 100644 --- a/src/app/components/tests/icon.test.ts +++ b/src/app/components/tests/icon.test.ts @@ -16,7 +16,7 @@ import { CoreIconComponent } from '@components/icon/icon'; import { renderWrapperComponent } from '@/tests/utils'; -describe('CoreIcon', () => { +describe('CoreIconComponent', () => { it('should render', async () => { // Act diff --git a/src/app/core/login/tests/init.page.test.ts b/src/app/core/login/tests/init.page.test.ts index f66a1ff8b..3271530f0 100644 --- a/src/app/core/login/tests/init.page.test.ts +++ b/src/app/core/login/tests/init.page.test.ts @@ -17,19 +17,21 @@ import { NavController } from '@ionic/angular'; import { CoreApp } from '@/app/services/app'; import { CoreInit } from '@services/init'; import { CoreLoginInitPage } from '@core/login/pages/init/init.page'; +import { CoreSites } from '@/app/services/sites'; import { SplashScreen } from '@/app/singletons/core.singletons'; import { mock, mockSingleton, renderComponent, RenderConfig } from '@/tests/utils'; -describe('CoreLogin Init Page', () => { +describe('CoreLoginInitPage', () => { let navController: NavController; let config: Partial; beforeEach(() => { - mockSingleton(SplashScreen, ['hide']); - mockSingleton(CoreInit, { ready: () => Promise.resolve() }); mockSingleton(CoreApp, { getRedirect: () => ({}) }); + mockSingleton(CoreInit, { ready: () => Promise.resolve() }); + mockSingleton(CoreSites, { isLoggedIn: () => false }); + mockSingleton(SplashScreen, ['hide']); navController = mock(['navigateRoot']); config = {