feat: scaffold Svelte app with shared types and scale calculation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4284f2533b
commit
a39122c504
12 files changed
+1491
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { scaleFromLine } from '../src/lib/scale';
|
||||
|
||||
describe('scaleFromLine', () => {
|
||||
it('returns pixels per mm', () => {
|
||||
expect(scaleFromLine({ x: 0, y: 0 }, { x: 300, y: 400 }, 100)).toBeCloseTo(5);
|
||||
});
|
||||
|
||||
it('rejects a non-positive or missing length', () => {
|
||||
expect(scaleFromLine({ x: 0, y: 0 }, { x: 100, y: 0 }, 0)).toBeNull();
|
||||
expect(scaleFromLine({ x: 0, y: 0 }, { x: 100, y: 0 }, -5)).toBeNull();
|
||||
expect(scaleFromLine({ x: 0, y: 0 }, { x: 100, y: 0 }, NaN)).toBeNull();
|
||||
});
|
||||
|
||||
it('rejects a line shorter than one pixel', () => {
|
||||
expect(scaleFromLine({ x: 10, y: 10 }, { x: 10.5, y: 10 }, 100)).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user