MOBILE-3320 tests: Fix tests
parent
d94630ce61
commit
3996880ab7
|
@ -12,22 +12,27 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { NavController } from '@ionic/angular';
|
||||||
|
|
||||||
import { AppComponent } from '@app/app.component';
|
import { AppComponent } from '@app/app.component';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { CoreLangProvider } from '@services/lang';
|
import { CoreLangProvider } from '@services/lang';
|
||||||
|
|
||||||
import { mock, renderComponent, RenderConfig } from '@/tests/utils';
|
import { mock, renderComponent, RenderConfig } from '@/tests/utils';
|
||||||
|
|
||||||
describe('App component', () => {
|
describe('AppComponent', () => {
|
||||||
|
|
||||||
let langProvider: CoreLangProvider;
|
let langProvider: CoreLangProvider;
|
||||||
|
let navController: NavController;
|
||||||
let config: Partial<RenderConfig>;
|
let config: Partial<RenderConfig>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
langProvider = mock<CoreLangProvider>(['clearCustomStrings']);
|
langProvider = mock<CoreLangProvider>(['clearCustomStrings']);
|
||||||
|
navController = mock<NavController>(['navigateRoot']);
|
||||||
config = {
|
config = {
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: CoreLangProvider, useValue: langProvider },
|
{ provide: CoreLangProvider, useValue: langProvider },
|
||||||
|
{ provide: NavController, useValue: navController },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -39,13 +44,14 @@ describe('App component', () => {
|
||||||
expect(fixture.nativeElement.querySelector('ion-router-outlet')).toBeTruthy();
|
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);
|
const fixture = await renderComponent(AppComponent, config);
|
||||||
|
|
||||||
fixture.componentInstance.ngOnInit();
|
fixture.componentInstance.ngOnInit();
|
||||||
CoreEvents.trigger(CoreEvents.LOGOUT);
|
CoreEvents.trigger(CoreEvents.LOGOUT);
|
||||||
|
|
||||||
expect(langProvider.clearCustomStrings).toHaveBeenCalled();
|
expect(langProvider.clearCustomStrings).toHaveBeenCalled();
|
||||||
|
expect(navController.navigateRoot).toHaveBeenCalledWith('/login/sites');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { CoreIconComponent } from '@components/icon/icon';
|
||||||
|
|
||||||
import { renderWrapperComponent } from '@/tests/utils';
|
import { renderWrapperComponent } from '@/tests/utils';
|
||||||
|
|
||||||
describe('CoreIcon', () => {
|
describe('CoreIconComponent', () => {
|
||||||
|
|
||||||
it('should render', async () => {
|
it('should render', async () => {
|
||||||
// Act
|
// Act
|
||||||
|
|
|
@ -17,19 +17,21 @@ import { NavController } from '@ionic/angular';
|
||||||
import { CoreApp } from '@/app/services/app';
|
import { CoreApp } from '@/app/services/app';
|
||||||
import { CoreInit } from '@services/init';
|
import { CoreInit } from '@services/init';
|
||||||
import { CoreLoginInitPage } from '@core/login/pages/init/init.page';
|
import { CoreLoginInitPage } from '@core/login/pages/init/init.page';
|
||||||
|
import { CoreSites } from '@/app/services/sites';
|
||||||
import { SplashScreen } from '@/app/singletons/core.singletons';
|
import { SplashScreen } from '@/app/singletons/core.singletons';
|
||||||
|
|
||||||
import { mock, mockSingleton, renderComponent, RenderConfig } from '@/tests/utils';
|
import { mock, mockSingleton, renderComponent, RenderConfig } from '@/tests/utils';
|
||||||
|
|
||||||
describe('CoreLogin Init Page', () => {
|
describe('CoreLoginInitPage', () => {
|
||||||
|
|
||||||
let navController: NavController;
|
let navController: NavController;
|
||||||
let config: Partial<RenderConfig>;
|
let config: Partial<RenderConfig>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockSingleton(SplashScreen, ['hide']);
|
|
||||||
mockSingleton(CoreInit, { ready: () => Promise.resolve() });
|
|
||||||
mockSingleton(CoreApp, { getRedirect: () => ({}) });
|
mockSingleton(CoreApp, { getRedirect: () => ({}) });
|
||||||
|
mockSingleton(CoreInit, { ready: () => Promise.resolve() });
|
||||||
|
mockSingleton(CoreSites, { isLoggedIn: () => false });
|
||||||
|
mockSingleton(SplashScreen, ['hide']);
|
||||||
|
|
||||||
navController = mock<NavController>(['navigateRoot']);
|
navController = mock<NavController>(['navigateRoot']);
|
||||||
config = {
|
config = {
|
||||||
|
|
Loading…
Reference in New Issue