Commit 25e2bb57 authored by Konstantin Schulz's avatar Konstantin Schulz
Browse files

added test for KWIC display

parent 940e425a
Pipeline #11838 passed with stages
in 2 minutes and 35 seconds
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
</ion-row> </ion-row>
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-button (click)="getExerciseList()" <ion-button (click)="getExerciseList(true)"
disabled="{{!hasVocChanged}}">{{ 'APPLY' | translate }} disabled="{{!hasVocChanged}}">{{ 'APPLY' | translate }}
</ion-button> </ion-button>
</ion-col> </ion-col>
......
...@@ -54,27 +54,26 @@ describe('ExerciseParametersPage', () => { ...@@ -54,27 +54,26 @@ describe('ExerciseParametersPage', () => {
it('should generate an exercise', (done) => { it('should generate an exercise', (done) => {
exerciseParametersPage.corpusService.annisResponse = {solutions: []}; exerciseParametersPage.corpusService.annisResponse = {solutions: []};
exerciseParametersPage.corpusService.initCurrentCorpus().then(() => { exerciseParametersPage.corpusService.initCurrentCorpus().then(async () => {
exerciseParametersPage.corpusService.currentTextRange = new ReplaySubject<TextRange>(1); exerciseParametersPage.corpusService.currentTextRange = new ReplaySubject<TextRange>(1);
exerciseParametersPage.corpusService.currentTextRange.next(new TextRange({start: [], end: []})); exerciseParametersPage.corpusService.currentTextRange.next(new TextRange({start: [], end: []}));
const h5pSpy: Spy = spyOn(exerciseParametersPage, 'getH5Pexercise').and.returnValue(Promise.resolve()); const h5pSpy: Spy = spyOn(exerciseParametersPage, 'getH5Pexercise').and.returnValue(Promise.resolve());
await exerciseParametersPage.generateExercise();
expect(exerciseParametersPage.corpusService.annisResponse.solutions).toBeFalsy();
expect(h5pSpy).toHaveBeenCalledTimes(1);
configMC.maxTextLength = 1;
exerciseParametersPage.corpusService.currentText = 'text';
exerciseParametersPage.generateExercise().then(() => { exerciseParametersPage.generateExercise().then(() => {
expect(exerciseParametersPage.corpusService.annisResponse.solutions).toBeFalsy(); }, () => {
expect(h5pSpy).toHaveBeenCalledTimes(1); expect(h5pSpy).toHaveBeenCalledTimes(1);
configMC.maxTextLength = 1; configMC.maxTextLength = 0;
exerciseParametersPage.corpusService.currentText = 'text'; exerciseParametersPage.corpusService.exercise.queryItems[0].phenomenon = Phenomenon.Lemma;
exerciseParametersPage.corpusService.exercise.type = ExerciseType.matching;
exerciseParametersPage.corpusService.exercise.queryItems.push(new QueryMC({values: []}));
exerciseParametersPage.generateExercise().then(() => { exerciseParametersPage.generateExercise().then(() => {
}, () => { }, () => {
expect(h5pSpy).toHaveBeenCalledTimes(1); expect(h5pSpy).toHaveBeenCalledTimes(1);
configMC.maxTextLength = 0; done();
exerciseParametersPage.corpusService.exercise.queryItems[0].phenomenon = Phenomenon.Lemma;
exerciseParametersPage.corpusService.exercise.type = ExerciseType.matching;
exerciseParametersPage.corpusService.exercise.queryItems.push(new QueryMC({values: []}));
exerciseParametersPage.generateExercise().then(() => {
}, () => {
expect(h5pSpy).toHaveBeenCalledTimes(1);
done();
});
}); });
}); });
}); });
......
...@@ -9,7 +9,7 @@ import {TranslateTestingModule} from '../translate-testing/translate-testing.mod ...@@ -9,7 +9,7 @@ import {TranslateTestingModule} from '../translate-testing/translate-testing.mod
import {APP_BASE_HREF} from '@angular/common'; import {APP_BASE_HREF} from '@angular/common';
describe('KwicPage', () => { describe('KwicPage', () => {
let component: KwicPage; let kwicPage: KwicPage;
let fixture: ComponentFixture<KwicPage>; let fixture: ComponentFixture<KwicPage>;
beforeEach(async(() => { beforeEach(async(() => {
...@@ -31,11 +31,16 @@ describe('KwicPage', () => { ...@@ -31,11 +31,16 @@ describe('KwicPage', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(KwicPage); fixture = TestBed.createComponent(KwicPage);
component = fixture.componentInstance; kwicPage = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(kwicPage).toBeTruthy();
const svgElement: SVGElement = document.querySelector(kwicPage.svgElementSelector);
expect(svgElement.innerHTML).toBeFalsy();
kwicPage.exerciseService.kwicGraphs = '<svg></svg>';
kwicPage.initVisualization();
expect(svgElement.innerHTML).toBeTruthy();
}); });
}); });
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