Skip to content

Commit

Permalink
Added missing tests and removed redundant todos
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Apr 4, 2024
1 parent 8f2263a commit bd1bebd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export class ProfileDifferenceChartComponent extends Streamed implements OnInit
this.plotter.plotCharts(this.profileA.totalDuration);
}

// TODO fix hover over the diff chart
private hookChartEvents(): void {
// used any to prevent typescript type gymnastic
const chartElement: any = document.getElementById(this.plotter.elementName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export class ProfileComparatorService extends Streamed {
this._onSelectionChanged.next();
}

// TODO check to be removed
public waitUntilProfilesCalculated(): Promise<void> {
return new Promise<void>((resolve) => {
const interval = setInterval(() => {
Expand All @@ -149,7 +148,6 @@ export class ProfileComparatorService extends Streamed {
this.updateWayPoints();
}

// TODO add tests for cached waypoints
/** Waypoints need to be cached to preserve the selection */
private updateWayPoints(): void {
this._wayPoints = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,24 @@ describe('WayPoints Difference Service', () => {
];
assertDivesWayPointsCompare(segments6_minutes11, segments4_minutes11, expected);
});

it('Comparison returns cached diff', () => {
// irrelevant profiles
schedules.dives[0].diveResult.wayPoints = wayPoints.calculateWayPoints(segments3_minutes6);
schedules.dives[1].diveResult.wayPoints = wayPoints.calculateWayPoints(segments6_minutes11);
dispatcher.sendInfoCalculated(1);
dispatcher.sendInfoCalculated(2);
expect(sut.difference).toBe(sut.difference);
});

it('Recalculated even same profile refreshes diff', () => {
// irrelevant profiles
schedules.dives[0].diveResult.wayPoints = wayPoints.calculateWayPoints(segments3_minutes6);
schedules.dives[1].diveResult.wayPoints = wayPoints.calculateWayPoints(segments6_minutes11);
dispatcher.sendInfoCalculated(1);
dispatcher.sendInfoCalculated(2);
const first = sut.difference;
dispatcher.sendInfoCalculated(2);
expect(first).not.toBe(sut.difference);
});
});

0 comments on commit bd1bebd

Please sign in to comment.