|
| 1 | +import { |
| 2 | + SVG_WIDTH, |
| 3 | + SVG_HEIGHT, |
| 4 | + GHOST_HEIGHT_PX, |
| 5 | + LOG_SCALE_MULTIPLIER, |
| 6 | + LINEAR_SCALE_MULTIPLIER, |
| 7 | + MAX_LOG_HEIGHT, |
| 8 | + MAX_LINEAR_HEIGHT, |
| 9 | + FONT_MAP, |
| 10 | + CONTRIBUTION_MILESTONES, |
| 11 | + STREAK_MILESTONES, |
| 12 | +} from './constants'; |
| 13 | + |
| 14 | +import { describe, it, expect } from 'vitest'; |
| 15 | + |
| 16 | +describe('SVG constants integrity', () => { |
| 17 | + it('should have valid SVG dimensions', () => { |
| 18 | + expect(SVG_WIDTH).toBe(600); |
| 19 | + expect(SVG_HEIGHT).toBe(420); |
| 20 | + }); |
| 21 | + it('should keep ghost height within safe rendering range', () => { |
| 22 | + expect(GHOST_HEIGHT_PX).toBeGreaterThan(0); |
| 23 | + expect(GHOST_HEIGHT_PX).toBeLessThan(10); |
| 24 | + }); |
| 25 | + it('should ensure log scale multiplier is larger than linear scale multiplier', () => { |
| 26 | + expect(LOG_SCALE_MULTIPLIER).toBeGreaterThan(LINEAR_SCALE_MULTIPLIER); |
| 27 | + expect(LINEAR_SCALE_MULTIPLIER).toBeGreaterThan(0); |
| 28 | + }); |
| 29 | + it('should contain valid font mappings', () => { |
| 30 | + expect(FONT_MAP.jetbrains).toContain('monospace'); |
| 31 | + expect(FONT_MAP.fira).toContain('monospace'); |
| 32 | + expect(FONT_MAP.roboto).toContain('sans-serif'); |
| 33 | + |
| 34 | + expect(Object.keys(FONT_MAP).length).toBeGreaterThan(0); |
| 35 | + }); |
| 36 | + it('should have correctly ordered contribution milestones', () => { |
| 37 | + expect(CONTRIBUTION_MILESTONES).toEqual([...CONTRIBUTION_MILESTONES].sort((a, b) => a - b)); |
| 38 | + |
| 39 | + expect(CONTRIBUTION_MILESTONES[0]).toBe(1); |
| 40 | + }); |
| 41 | + it('should have valid streak milestones in ascending order', () => { |
| 42 | + expect(STREAK_MILESTONES).toEqual([...STREAK_MILESTONES].sort((a, b) => a - b)); |
| 43 | + |
| 44 | + expect(STREAK_MILESTONES[0]).toBe(3); |
| 45 | + }); |
| 46 | +}); |
0 commit comments