Skip to content

Commit

Permalink
Add missing client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rstief committed May 21, 2024
1 parent 42a726d commit 2bdb6f8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@ describe('AdminImportStandardizedCompetenciesComponent', () => {
});

it('should open details', () => {
const competencyToOpen = { id: 2, isVisible: true };
component['importData'] = { knowledgeAreas: [], sources: [{ id: 1, title: 'any source' }] };
const competencyToOpen = { id: 2, isVisible: true, sourceId: 1 };
const knowledgeAreaTitle = 'knowledgeArea';

component['openCompetencyDetails'](competencyToOpen, knowledgeAreaTitle);

expect(component['selectedCompetency']).toEqual(competencyToOpen);
expect(component['knowledgeAreaTitle']).toEqual(knowledgeAreaTitle);
expect(component['sourceString']).toBeTruthy();
});

it('should close details', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ describe('CourseImportStandardizedCompetenciesComponent', () => {
});

it('should open details', () => {
const competencyToOpen = { id: 2, isVisible: true, selected: true };
component['sources'] = [{ id: 1, title: 'title1', author: 'author1' }];
const competencyToOpen = { id: 2, isVisible: true, selected: true, sourceId: 1 };

component['openCompetencyDetails'](competencyToOpen);

expect(component['selectedCompetency']).toEqual(competencyToOpen);
expect(component['sourceString']).toBeTruthy();
});

it('should close details', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { KnowledgeArea, KnowledgeAreaDTO, StandardizedCompetency } from 'app/entities/competency/standardized-competency.model';
import { KnowledgeArea, KnowledgeAreaDTO, Source, StandardizedCompetency } from 'app/entities/competency/standardized-competency.model';
import { take } from 'rxjs';
import { CompetencyTaxonomy } from 'app/entities/competency.model';
import { StandardizedCompetencyService } from 'app/shared/standardized-competencies/standardized-competency.service';
Expand Down Expand Up @@ -107,4 +107,24 @@ describe('StandardizedCompetencyService', () => {

expect(actualResult.body).toEqual(expectedResult);
}));

it('should get sources', fakeAsync(() => {
let actualSources = new HttpResponse<Source[]>();
const expectedSources: Source[] = [
{ id: 1, title: 'source1' },
{ id: 2, title: 'source2' },
];
const returnedFromService = [...expectedSources];

standardizedCompetencyService
.getSources()
.pipe(take(1))
.subscribe((resp) => (actualSources = resp));

const req = httpTestingController.expectOne({ method: 'GET' });
req.flush(returnedFromService);
tick();

expect(actualSources.body).toEqual(expectedSources);
}));
});

0 comments on commit 2bdb6f8

Please sign in to comment.