-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from josefbogar/Add_IgnoredIssues_Test2
IgnoredIssues tests
- Loading branch information
Showing
1 changed file
with
48 additions
and
9 deletions.
There are no files selected for viewing
57 changes: 48 additions & 9 deletions
57
projects/planner/src/app/shared/IgnoredIssues.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
|
||
}); |