nordic-skating / local-littlejs / files / test / strength.test.ts
Branch local-littlejs · default branch · all branches
strength.test.ts
| 1 | import { describe, expect, it } from 'vitest' |
| 2 | import { singingFrequency } from '../src/ice/acoustics.js' |
| 3 | import { BREAKING_THICKNESS, CRACKING_THICKNESS, SAFE_THICKNESS, bearingThickness } from '../src/ice/strength.js' |
| 4 | import { MAX_THICKNESS, MIN_THICKNESS } from '../src/world/lake.js' |
| 5 | |
| 6 | describe('ice strength', () => { |
| 7 | it('needs twice the ice for four times the load', () => { |
| 8 | expect(bearingThickness(320, 7) / bearingThickness(80, 7)).toBeCloseTo(2, 10) |
| 9 | }) |
| 10 | |
| 11 | it('gives a skater zones of 2.2, 3.4 and 4.8 cm', () => { |
| 12 | expect(BREAKING_THICKNESS * 100).toBeCloseTo(2.2, 1) |
| 13 | expect(CRACKING_THICKNESS * 100).toBeCloseTo(3.4, 1) |
| 14 | expect(SAFE_THICKNESS * 100).toBeCloseTo(4.8, 1) |
| 15 | }) |
| 16 | |
| 17 | it('puts the film\'s ice in the zone that sings', () => { |
| 18 | expect(0.041).toBeGreaterThan(CRACKING_THICKNESS) |
| 19 | expect(0.041).toBeLessThan(SAFE_THICKNESS) |
| 20 | }) |
| 21 | |
| 22 | it('has every zone somewhere on the lake, and a pitch that tells them apart', () => { |
| 23 | expect(MIN_THICKNESS).toBeLessThan(BREAKING_THICKNESS) |
| 24 | expect(MAX_THICKNESS).toBeGreaterThan(SAFE_THICKNESS) |
| 25 | // Breaking ice sings above 1.4 kHz, safe ice below 640 Hz: more than an octave apart. |
| 26 | expect(singingFrequency(BREAKING_THICKNESS)).toBeGreaterThan(1390) |
| 27 | expect(singingFrequency(SAFE_THICKNESS)).toBeLessThan(640) |
| 28 | }) |
| 29 | }) |