-
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 #9 from josefbogar/newTestDiver2
New diver tests
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
"**/*{.,-,_}{test,spec}.{ts,js}", | ||
"**/{test,spec}{.,-,_}*.{ts,js}" | ||
], | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { EventType } 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; | ||
|
||
beforeEach(() => { | ||
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 = service.getIgnoredIssues(); | ||
|
||
expect(ignoredIssues).toContain(EventType.switchToHigherN2); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Diver} from './Diver'; | ||
import { Tank} from './Tanks'; | ||
|
||
describe('Diver', () => { | ||
|
||
it('Diver.rmv', () => { | ||
const diver = new Diver(20, 25); | ||
expect(diver.rmv).toBe(20); | ||
}); | ||
|
||
it('Diver.stressRmv', () => { | ||
const diver = new Diver(20, 30); | ||
expect(diver.stressRmv).toBe(30); | ||
}); | ||
|
||
it('should correctly change rmv and stressRmv', () => { | ||
const diver = new Diver(20, 30); | ||
diver.rmv = 25; | ||
diver.stressRmv = 35; | ||
expect(diver.rmv).toBe(25); | ||
expect(diver.stressRmv).toBe(35); | ||
}); | ||
|
||
it('should correctly assign default rmv and stressRmv if undefined', () => { | ||
const diver = new Diver(undefined, undefined); | ||
expect(diver.rmv).toBe(Diver.defaultSac); | ||
expect(diver.stressRmv).toBe(Diver.defaultSac * 1.5); | ||
}); | ||
|
||
it('constructor with default values', () => { | ||
const diver = new Diver(); | ||
expect(diver.rmv).toBe(Diver.defaultSac); | ||
expect(diver.stressRmv).toBe(Diver.defaultSac * 1.5); | ||
}); | ||
|
||
it('constructor with rmv defined only ', () => { | ||
const diver = new Diver(18); | ||
expect(diver.rmv).toBe(18); | ||
expect(diver.stressRmv).toBe(18 * 1.5); | ||
}); | ||
|
||
it('constructor with defined values ', () => { | ||
const diver = new Diver(30,50); | ||
expect(diver.rmv).toBe(30); | ||
expect(diver.stressRmv).toBe(50); | ||
}); | ||
|
||
it('should correctly calculate teamStressRmv', () =>{ | ||
const stressRmv = 30; | ||
const diver = new Diver(20, stressRmv); | ||
expect(diver.teamStressRmv).toBe(60); | ||
}); | ||
|
||
it('should correctly calculate gas SAC based on tank size', () => { | ||
const diver = new Diver (20, 30); | ||
const tank = new Tank(100, 100, 20); | ||
tank.size = 100; | ||
expect(diver.gasSac(tank)).toBe(0.2); | ||
}); | ||
|
||
it('should correctly calculate gas SAC based on instance properties', () => { | ||
const diver = new Diver(); | ||
const tank = new Tank(100, 100, 20); | ||
expect(diver.gasSac(tank)).toBe(0.2); | ||
}); | ||
|
||
it('should correctly pass values from Diver instance', () => { | ||
const diver1 = new Diver(30, 45); | ||
const diver2 = new Diver(); | ||
diver2.loadFrom(diver1); | ||
expect(diver2.rmv).toBe(30); | ||
expect(diver2.stressRmv).toBe(45); | ||
}); | ||
|
||
}); | ||
|
||
|