diff --git a/.vscode/settings.json b/.vscode/settings.json index 41d3f578..3953d5a4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,4 +16,4 @@ "**/*{.,-,_}{test,spec}.{ts,js}", "**/{test,spec}{.,-,_}*.{ts,js}" ], -} + } diff --git a/projects/planner/src/app/shared/IgnoredIssues.service.spec.ts b/projects/planner/src/app/shared/IgnoredIssues.service.spec.ts new file mode 100644 index 00000000..954c59f9 --- /dev/null +++ b/projects/planner/src/app/shared/IgnoredIssues.service.spec.ts @@ -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); + }); + }); +}); diff --git a/projects/scuba-physics/src/lib/Diver.spec.ts b/projects/scuba-physics/src/lib/Diver.spec.ts new file mode 100644 index 00000000..201f5bc6 --- /dev/null +++ b/projects/scuba-physics/src/lib/Diver.spec.ts @@ -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); + }); + +}); + +