Fixes tests

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