Skip to content

Commit

Permalink
add tests to observables
Browse files Browse the repository at this point in the history
  • Loading branch information
nevio18324 authored and peggimann committed Oct 23, 2024
1 parent 123f6f5 commit 7fb37bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0",
"start": "ng serve",
"build": "ng build",
"build:staging": "ng build --configuration staging",
"watch": "ng build --watch --configuration development",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { MatIconModule } from '@angular/material/icon';
import { ActivatedRoute } from '@angular/router';
import { ScoringComponent } from '../../shared/custom/scoring/scoring.component';
import { ConfidenceComponent } from '../confidence/confidence.component';
import { RefreshDataService } from '../../services/refresh-data.service';

const keyResultServiceMock = {
getFullKeyResult: jest.fn(),
Expand Down Expand Up @@ -87,4 +88,21 @@ describe('KeyresultDetailComponent', () => {
const button = fixture.debugElement.query(By.css('[data-testId="add-check-in"]'));
expect(button).toBeFalsy();
});

it('should trigger observable when subject gets next value', () => {
const spy = jest.spyOn(component, 'loadKeyResult');
const refreshDataService = TestBed.inject(RefreshDataService);
refreshDataService.reloadKeyResultSubject.next();
expect(spy).toHaveBeenCalled();
});

it('should close subscription on destroy', () => {
const spyNext = jest.spyOn(component.ngDestroy$, 'next');
const spyComplete = jest.spyOn(component.ngDestroy$, 'complete');

component.ngOnDestroy();

expect(spyNext).toHaveBeenCalled();
expect(spyComplete).toHaveBeenCalled();
});
});

0 comments on commit 7fb37bf

Please sign in to comment.