diff --git a/projects/planner/src/app/shared/IgnoredIssues.service.spec.ts b/projects/planner/src/app/shared/IgnoredIssues.service.spec.ts index 0f7c86d2..6a522bbb 100644 --- a/projects/planner/src/app/shared/IgnoredIssues.service.spec.ts +++ b/projects/planner/src/app/shared/IgnoredIssues.service.spec.ts @@ -1,4 +1,4 @@ -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'; @@ -6,20 +6,59 @@ 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); + }); + });