Fixes tests

parent 7273ebd7
......@@ -76,17 +76,13 @@ describe('QuizManagerComponent', () => {
}
));
it('should be created', (
() => {
expect(component).toBeTruthy();
}
));
it('should be created', async(() => {
expect(component).toBeTruthy();
}));
it('should contain a TYPE reference', (
() => {
expect(QuizManagerComponent.TYPE).toEqual('QuizManagerComponent');
}
));
it('should contain a TYPE reference', async(() => {
expect(QuizManagerComponent.TYPE).toEqual('QuizManagerComponent');
}));
describe('#addQuestion', () => {
it('should add a question', inject([ActiveQuestionGroupService], (activeQuestionGroupService: ActiveQuestionGroupService) => {
......
......@@ -52,23 +52,22 @@ export class QuizManagerComponent implements OnDestroy {
this.footerBarService.footerElemMemberGroup,
this.footerBarService.footerElemSound,
]);
this.activeQuestionGroupService.loadData().then(() => {
this.questionGroupItem = activeQuestionGroupService.activeQuestionGroup;
this.footerBarService.footerElemStartQuiz.isActive = activeQuestionGroupService.activeQuestionGroup.isValid();
this.footerBarService.footerElemStartQuiz.onClickCallback = async (self: FooterbarElement) => {
if (!self.isActive) {
return;
}
this.currentQuizService.quiz = this.questionGroupItem;
await this.currentQuizService.cacheQuiz();
await this.lobbyApiService.putLobby({
quiz: this.currentQuizService.quiz.serialize(),
}).toPromise();
this.router.navigate(['/quiz', 'flow', 'lobby']);
};
});
this.activeQuestionGroupService.loadData();
this.questionGroupItem = activeQuestionGroupService.activeQuestionGroup;
this.footerBarService.footerElemStartQuiz.isActive = activeQuestionGroupService.activeQuestionGroup.isValid();
this.footerBarService.footerElemStartQuiz.onClickCallback = async (self: FooterbarElement) => {
if (!self.isActive) {
return;
}
this.currentQuizService.quiz = this.questionGroupItem;
await this.currentQuizService.cacheQuiz();
await this.lobbyApiService.putLobby({
quiz: this.currentQuizService.quiz.serialize(),
}).toPromise();
this.router.navigate(['/quiz', 'flow', 'lobby']);
};
}
public ngOnDestroy(): void {
......
......@@ -3,6 +3,7 @@ import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { IQuestionGroup } from 'arsnova-click-v2-types/src/questions/interfaces';
import { questionGroupReflection } from 'arsnova-click-v2-types/src/questions/questionGroup_reflection';
import { Subscription } from 'rxjs';
import { DB_TABLE, STORAGE_KEY } from '../../shared/enums';
import { FooterBarService } from '../footer-bar/footer-bar.service';
import { StorageService } from '../storage/storage.service';
......@@ -81,13 +82,11 @@ export class ActiveQuestionGroupService {
}
}
public loadData(): Promise<void> {
return new Promise(async resolve => {
const parsedObject = await this.storageService.read(DB_TABLE.CONFIG, STORAGE_KEY.ACTIVE_QUESTION_GROUP).toPromise();
public loadData(): Subscription {
return this.storageService.read(DB_TABLE.CONFIG, STORAGE_KEY.ACTIVE_QUESTION_GROUP).subscribe(parsedObject => {
if (parsedObject) {
this._activeQuestionGroup = questionGroupReflection[parsedObject.TYPE](parsedObject);
}
resolve();
});
}
......
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