Skip to content

Commit

Permalink
Merge pull request #10 from josefbogar/Add_IgnoredIssues_Test2
Browse files Browse the repository at this point in the history
IgnoredIssues tests
  • Loading branch information
jirkapok authored Sep 9, 2024
2 parents cf8d435 + a7effc7 commit 01d071f
Showing 1 changed file with 48 additions and 9 deletions.
57 changes: 48 additions & 9 deletions projects/planner/src/app/shared/IgnoredIssues.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,64 @@
import { EventType } from 'scuba-physics';
import { EventType, Event, StandardGases } from 'scuba-physics';
import { ApplicationSettingsService } from './ApplicationSettings';
import { IgnoredIssuesService } from './IgnoredIssues.service';
import { UnitConversion } from './UnitConversion';

describe('IgnoredIssuesService', () => {
let appSettings: ApplicationSettingsService;
let service: IgnoredIssuesService;
let unitConversion: UnitConversion;

const testEvents: Event[] = [
Event.create(EventType.switchToHigherN2, 0, 0, StandardGases.air),
Event.create(EventType.highGasDensity, 0, 0, StandardGases.air),
Event.create(EventType.noDecoEnd, 0, 0, StandardGases.air),
Event.create(EventType.highAscentSpeed, 0, 0, StandardGases.oxygen)
];

beforeEach(() => {
unitConversion = new UnitConversion();
const unitConversion = new UnitConversion();
appSettings = new ApplicationSettingsService(unitConversion);
service = new IgnoredIssuesService(appSettings);

});

describe('ignoredIssues', () => {
it('should add switchToHigherN2 to ignoredIssues when icdIgnored is true', () => {
appSettings.settings.icdIgnored = true;
const ignoredIssues: EventType[] = []; // service.getIgnoredIssues();
it('should filter out switchToHigherN2 when icdIgnored is true', () => {
appSettings.icdIgnored = true;
const filteredResult = service.filterIgnored(testEvents);

expect(ignoredIssues).not.toContain(EventType.switchToHigherN2);
});
expect(filteredResult).toEqual([
Event.create(EventType.highGasDensity, 0, 0, StandardGases.air),
Event.create(EventType.noDecoEnd, 0, 0, StandardGases.air),
Event.create(EventType.highAscentSpeed, 0, 0, StandardGases.oxygen)
]);
});

it('should filter out highGasDensity when densityIgnored is true', () => {
appSettings.densityIgnored = true;
const filteredResult = service.filterIgnored(testEvents);

expect(filteredResult).toEqual([
Event.create(EventType.switchToHigherN2, 0, 0, StandardGases.air),
Event.create(EventType.noDecoEnd, 0, 0, StandardGases.air),
Event.create(EventType.highAscentSpeed, 0, 0, StandardGases.oxygen)
]);
});

it('should filter out noDecoEnd when noDecoIgnored is true', () => {
appSettings.noDecoIgnored = true;
const filteredResult = service.filterIgnored(testEvents);

expect(filteredResult).toEqual([
Event.create(EventType.switchToHigherN2, 0, 0, StandardGases.air),
Event.create(EventType.highGasDensity, 0, 0, StandardGases.air),
Event.create(EventType.highAscentSpeed, 0, 0, StandardGases.oxygen)
]);
});

it('should not filter out any issues when every issues are off', () => {

const filteredResult = service.filterIgnored(testEvents);

expect(filteredResult).toEqual(testEvents);
});

});

0 comments on commit 01d071f

Please sign in to comment.