Fixes tests

parent c2147fce
......@@ -17,8 +17,8 @@ export class TranslateServiceMock extends TranslateService {
const currentLoader: TranslateLoader = new TranslateFakeLoader();
const compiler: TranslateCompiler = new TranslateFakeCompiler();
const parser: TranslateParser = new TranslateDefaultParser();
const missingTranslationParser: MissingTranslationHandler = new FakeMissingTranslationHandler();
const missingTranslationHandler: MissingTranslationHandler = new FakeMissingTranslationHandler();
super(translateStore, currentLoader, compiler, parser, missingTranslationParser);
super(translateStore, currentLoader, compiler, parser, missingTranslationHandler, true, true, true, 'en');
}
}
......@@ -22,6 +22,7 @@ import { ThemesService } from '../../service/themes/themes.service';
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
import { SharedModule } from '../../shared/shared.module';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { AdminOverviewComponent } from './admin-overview.component';
......@@ -32,7 +33,7 @@ describe('AdminOverviewComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientTestingModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, HttpClientTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......@@ -41,8 +42,7 @@ describe('AdminOverviewComponent', () => {
}),
],
providers: [
RxStompService,
{
RxStompService, {
provide: TranslateService,
useClass: TranslateServiceMock,
}, I18nService, {
......
......@@ -28,6 +28,7 @@ import { TrackingMockService } from '../../service/tracking/tracking.mock.servic
import { TrackingService } from '../../service/tracking/tracking.service';
import { UserService } from '../../service/user/user.service';
import { SharedModule } from '../../shared/shared.module';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { QuizAdminComponent } from './quiz-admin.component';
describe('QuizAdminComponent', () => {
......@@ -37,7 +38,7 @@ describe('QuizAdminComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientTestingModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, HttpClientTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......@@ -46,8 +47,7 @@ describe('QuizAdminComponent', () => {
}),
],
providers: [
RxStompService,
{
RxStompService, {
provide: TranslateService,
useClass: TranslateServiceMock,
}, I18nService, {
......
......@@ -27,6 +27,7 @@ import { TrackingMockService } from '../../service/tracking/tracking.mock.servic
import { TrackingService } from '../../service/tracking/tracking.service';
import { UserService } from '../../service/user/user.service';
import { SharedModule } from '../../shared/shared.module';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { UserAdminComponent } from './user-admin.component';
......@@ -41,7 +42,7 @@ describe('UserAdminComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientTestingModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, HttpClientTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......
......@@ -21,6 +21,7 @@ import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
import { SharedModule } from '../../shared/shared.module';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { FooterBarComponent } from './footer-bar.component';
......@@ -31,7 +32,7 @@ describe('FooterBarComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientTestingModule, NgbModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, HttpClientTestingModule, NgbModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......
......@@ -16,6 +16,7 @@ import { SharedService } from '../../service/shared/shared.service';
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
import { SharedModule } from '../../shared/shared.module';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { HeaderComponent } from './header.component';
describe('HeaderComponent', () => {
......@@ -25,7 +26,7 @@ describe('HeaderComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientTestingModule, NgbModule,
I18nTestingModule, SharedModule, RouterTestingModule, HttpClientTestingModule, NgbModule,
],
providers: [
HeaderLabelService, {
......@@ -69,18 +70,22 @@ describe('HeaderComponent', () => {
expect(HeaderComponent.TYPE).toEqual('HeaderComponent');
}));
it('#openConnectionQualityModal', (inject([TrackingService, NgbModal, ConnectionService],
(trackingService: TrackingService, modalService: NgbModal, connectionService: ConnectionService) => {
const modalContent = 'testcontent' as unknown as TemplateRef<any>;
it('#openConnectionQualityModal', (
inject([TrackingService, NgbModal, ConnectionService],
(trackingService: TrackingService, modalService: NgbModal, connectionService: ConnectionService) => {
const modalContent = 'testcontent' as unknown as TemplateRef<any>;
spyOn(trackingService, 'trackClickEvent').and.callFake(() => {});
spyOn(modalService, 'open').and.callFake(() => ({} as NgbModalRef));
spyOn(connectionService, 'calculateRTT').and.callFake(() => {});
spyOn(trackingService, 'trackClickEvent').and.callFake(() => {});
spyOn(modalService, 'open').and.callFake(() => (
{} as NgbModalRef
));
spyOn(connectionService, 'calculateRTT').and.callFake(() => {});
component.openConnectionQualityModal(modalContent);
component.openConnectionQualityModal(modalContent);
expect(trackingService.trackClickEvent).toHaveBeenCalled();
expect(modalService.open).toHaveBeenCalledWith(modalContent);
expect(connectionService.calculateRTT).toHaveBeenCalled();
})));
expect(trackingService.trackClickEvent).toHaveBeenCalled();
expect(modalService.open).toHaveBeenCalledWith(modalContent);
expect(connectionService.calculateRTT).toHaveBeenCalled();
})
));
});
......@@ -18,6 +18,7 @@ import { StorageService } from '../../service/storage/storage.service';
import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { UserService } from '../../service/user/user.service';
import { SharedModule } from '../../shared/shared.module';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { KeyOutputComponent } from '../key-output/key-output.component';
import { I18nManagerOverviewComponent } from './i18n-manager-overview.component';
......@@ -29,7 +30,7 @@ describe('I18nManagerOverviewComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
JwtModule.forRoot({
I18nTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......@@ -38,8 +39,7 @@ describe('I18nManagerOverviewComponent', () => {
}), HttpClientTestingModule, NgbModalModule, SharedModule, PipesModule, RouterTestingModule, InfiniteScrollModule,
],
providers: [
RxStompService,
{
RxStompService, {
provide: TranslateService,
useClass: TranslateServiceMock,
}, {
......
......@@ -24,6 +24,7 @@ import { SettingsService } from '../../service/settings/settings.service';
import { SharedService } from '../../service/shared/shared.service';
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { LivePreviewComponent } from './live-preview.component';
......@@ -34,14 +35,13 @@ describe('LivePreviewComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule, HttpClientTestingModule, HeaderModule, NgbModule,
I18nTestingModule, RouterTestingModule, HttpClientTestingModule, HeaderModule, NgbModule,
],
providers: [
MarkdownService, {
provide: MarkedOptions,
useValue: {},
},
QuestionTextService, {
}, QuestionTextService, {
provide: ConnectionService,
useClass: ConnectionMockService,
}, {
......
......@@ -8,6 +8,7 @@ import { TranslateServiceMock } from '../../../_mocks/_services/TranslateService
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
import { SharedModule } from '../../shared/shared.module';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { MarkdownBarComponent } from './markdown-bar.component';
......@@ -18,7 +19,7 @@ describe('MarkdownBarComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientTestingModule,
I18nTestingModule, SharedModule, RouterTestingModule, HttpClientTestingModule,
],
providers: [
{
......
......@@ -21,6 +21,7 @@ import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
import { SharedModule } from '../../shared/shared.module';
import { I18nTestingModule } from '../../shared/testing/i18n-testing/i18n-testing.module';
import { AvailableQuizzesComponent } from './available-quizzes.component';
......@@ -31,7 +32,7 @@ describe('AvailableQuizzesComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule.withRoutes([]), HttpClientTestingModule, NgbModule,
I18nTestingModule, SharedModule, RouterTestingModule.withRoutes([]), HttpClientTestingModule, NgbModule,
],
providers: [
{
......@@ -102,18 +103,20 @@ describe('AvailableQuizzesComponent', () => {
expect(activeModal.close).toHaveBeenCalled();
})));
it('#startQuiz', (inject([QuizService, TrackingService], (quizService: QuizService, trackingService: TrackingService) => {
const quiz = quizService.quiz;
it('#startQuiz', (
inject([QuizService, TrackingService], (quizService: QuizService, trackingService: TrackingService) => {
const quiz = quizService.quiz;
spyOn(trackingService, 'trackClickEvent').and.callFake(() => {});
spyOn(trackingService, 'trackClickEvent').and.callFake(() => {});
component.startQuiz(quiz);
component.startQuiz(quiz);
expect(trackingService.trackClickEvent).toHaveBeenCalled();
})));
expect(trackingService.trackClickEvent).toHaveBeenCalled();
})
));
it('#editQuiz',
(inject([QuizService, TrackingService, QuizService, Router], (quizService: QuizService, trackingService: TrackingService, router: Router) => {
it('#editQuiz', (
inject([QuizService, TrackingService, QuizService, Router], (quizService: QuizService, trackingService: TrackingService, router: Router) => {
const quiz = quizService.quiz;
spyOn(trackingService, 'trackClickEvent').and.callFake(() => {});
......@@ -124,5 +127,6 @@ describe('AvailableQuizzesComponent', () => {
expect(trackingService.trackClickEvent).toHaveBeenCalled();
expect(quizService.quiz).toEqual(quiz);
expect(component.next).toHaveBeenCalled();
})));
})
));
});
......@@ -24,6 +24,7 @@ import { SharedService } from '../../../service/shared/shared.service';
import { StorageService } from '../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../service/storage/storage.service.mock';
import { SharedModule } from '../../../shared/shared.module';
import { I18nTestingModule } from '../../../shared/testing/i18n-testing/i18n-testing.module';
import { ConfidenceRateComponent } from './confidence-rate.component';
describe('QuizFlow: ConfidenceRateComponent', () => {
......@@ -33,7 +34,7 @@ describe('QuizFlow: ConfidenceRateComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......
......@@ -29,6 +29,7 @@ import { StorageServiceMock } from '../../../service/storage/storage.service.moc
import { TrackingMockService } from '../../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../../service/tracking/tracking.service';
import { SharedModule } from '../../../shared/shared.module';
import { I18nTestingModule } from '../../../shared/testing/i18n-testing/i18n-testing.module';
import { LeaderboardComponent } from './leaderboard.component';
......@@ -40,7 +41,7 @@ describe('LeaderboardComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......
......@@ -32,6 +32,7 @@ import { TrackingMockService } from '../../../service/tracking/tracking.mock.ser
import { TrackingService } from '../../../service/tracking/tracking.service';
import { UserService } from '../../../service/user/user.service';
import { SharedModule } from '../../../shared/shared.module';
import { I18nTestingModule } from '../../../shared/testing/i18n-testing/i18n-testing.module';
import { QuizLobbyComponent } from './quiz-lobby.component';
......@@ -42,7 +43,7 @@ describe('QuizLobbyComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule, SharedModule, QRCodeModule, NgbModule, HttpClientTestingModule,
I18nTestingModule, RouterTestingModule, SharedModule, QRCodeModule, NgbModule, HttpClientTestingModule,
],
providers: [
MarkdownService, {
......
......@@ -21,6 +21,7 @@ import { StorageServiceMock } from '../../../../service/storage/storage.service.
import { TrackingMockService } from '../../../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../../../service/tracking/tracking.service';
import { SharedModule } from '../../../../shared/shared.module';
import { I18nTestingModule } from '../../../../shared/testing/i18n-testing/i18n-testing.module';
import { ConfidenceRateComponent } from './confidence-rate.component';
......@@ -31,14 +32,13 @@ describe('QuizResults: ConfidenceRateComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule,
I18nTestingModule, SharedModule, RouterTestingModule,
],
providers: [
MarkdownService, {
provide: MarkedOptions,
useValue: {},
},
{
}, {
provide: StorageService,
useClass: StorageServiceMock,
}, NgbActiveModal, {
......
......@@ -26,6 +26,7 @@ import { StorageServiceMock } from '../../../../service/storage/storage.service.
import { TrackingMockService } from '../../../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../../../service/tracking/tracking.service';
import { SharedModule } from '../../../../shared/shared.module';
import { I18nTestingModule } from '../../../../shared/testing/i18n-testing/i18n-testing.module';
import { ProgressBarAnonymousComponent } from './progress-bar-anonymous/progress-bar-anonymous.component';
import { ProgressBarFreetextComponent } from './progress-bar-freetext/progress-bar-freetext.component';
import { ProgressBarMultipleChoiceComponent } from './progress-bar-multiple-choice/progress-bar-multiple-choice.component';
......@@ -42,7 +43,7 @@ describe('ProgressBarComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, HttpClientTestingModule,
I18nTestingModule, SharedModule, RouterTestingModule, HttpClientTestingModule,
],
providers: [
MarkdownService, {
......
......@@ -29,6 +29,7 @@ import { StorageServiceMock } from '../../../../service/storage/storage.service.
import { TrackingMockService } from '../../../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../../../service/tracking/tracking.service';
import { SharedModule } from '../../../../shared/shared.module';
import { I18nTestingModule } from '../../../../shared/testing/i18n-testing/i18n-testing.module';
import { QuestionDetailsComponent } from './question-details.component';
describe('QuestionDetailsComponent', () => {
......@@ -38,7 +39,7 @@ describe('QuestionDetailsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......
......@@ -28,6 +28,7 @@ import { SharedService } from '../../../service/shared/shared.service';
import { StorageService } from '../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../service/storage/storage.service.mock';
import { SharedModule } from '../../../shared/shared.module';
import { I18nTestingModule } from '../../../shared/testing/i18n-testing/i18n-testing.module';
import { VotingQuestionComponent } from '../voting/voting-question/voting-question.component';
import { ConfidenceRateComponent } from './confidence-rate/confidence-rate.component';
import { ProgressBarAnonymousComponent } from './progress-bar/progress-bar-anonymous/progress-bar-anonymous.component';
......@@ -48,7 +49,7 @@ describe('QuizResultsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......
......@@ -7,6 +7,7 @@ import { I18nService } from '../../../../service/i18n/i18n.service';
import { StorageService } from '../../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../../service/storage/storage.service.mock';
import { SharedModule } from '../../../../shared/shared.module';
import { I18nTestingModule } from '../../../../shared/testing/i18n-testing/i18n-testing.module';
import { ReadingConfirmationProgressComponent } from './reading-confirmation-progress.component';
......@@ -17,14 +18,13 @@ describe('Quiz-Results: ReadingConfirmationComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule,
I18nTestingModule, SharedModule, RouterTestingModule,
],
providers: [
MarkdownService, {
provide: MarkedOptions,
useValue: {},
},
{
}, {
provide: StorageService,
useClass: StorageServiceMock,
}, I18nService, {
......
......@@ -25,6 +25,7 @@ import { SettingsService } from '../../../service/settings/settings.service';
import { StorageService } from '../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../service/storage/storage.service.mock';
import { SharedModule } from '../../../shared/shared.module';
import { I18nTestingModule } from '../../../shared/testing/i18n-testing/i18n-testing.module';
import { ReadingConfirmationComponent } from './reading-confirmation.component';
......@@ -35,7 +36,7 @@ describe('QuizFlow: ReadingConfirmationComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, RouterTestingModule, JwtModule.forRoot({
I18nTestingModule, SharedModule, RouterTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Subject } from 'rxjs';
import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
import { environment } from '../../../environments/environment';
......@@ -27,8 +26,6 @@ export class InfoComponent implements OnInit, OnDestroy, AfterViewInit {
private trackingService: TrackingService,
private route: ActivatedRoute,
private headerLabelService: HeaderLabelService,
private translate: TranslateService,
private cdRef: ChangeDetectorRef,
) {
headerLabelService.headerLabel = 'region.footer.about.title';
......@@ -38,8 +35,6 @@ export class InfoComponent implements OnInit, OnDestroy, AfterViewInit {
this.footerBarService.footerElemHome, this.footerBarService.footerElemTranslation, this.footerBarService.footerElemTheme,
]);
console.log(this.translate, this.cdRef);
if (environment.infoAboutTabEnabled) {
this.infoButtons.push({
id: 'about',
......
......@@ -24,6 +24,7 @@ import { StorageService } from '../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../service/storage/storage.service.mock';
import { UserService } from '../../../service/user/user.service';
import { SharedModule } from '../../../shared/shared.module';
import { I18nTestingModule } from '../../../shared/testing/i18n-testing/i18n-testing.module';
import { NicknameInputComponent } from './nickname-input.component';
......@@ -34,7 +35,7 @@ describe('NicknameInputComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
JwtModule.forRoot({
I18nTestingModule, JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
......@@ -43,8 +44,7 @@ describe('NicknameInputComponent', () => {
}), RouterTestingModule, HttpClientTestingModule, FontAwesomeModule, SharedModule,
],
providers: [
RxStompService,
{
RxStompService, {
provide: StorageService,
useClass: StorageServiceMock,
}, {
......
......@@ -72,7 +72,6 @@ export class RootComponent implements OnInit, AfterViewInit {
}
public ngOnInit(): void {
console.log(this.translateService);
if (isPlatformBrowser(this.platformId)) {
if (localStorage.getItem('hashtags')) {
// Migrate arsnova.click v1 quizzes
......
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import {
DEFAULT_LANGUAGE,
FakeMissingTranslationHandler,
MissingTranslationHandler,
TranslateCompiler,
......@@ -35,6 +36,9 @@ import { TranslateServiceMock } from '../../../../_mocks/_services/TranslateServ
}, {
provide: MissingTranslationHandler,
useClass: FakeMissingTranslationHandler,
}, {
provide: DEFAULT_LANGUAGE,
useValue: 'en',
}, {
provide: USE_DEFAULT_LANG,
useValue: 'en',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment