forked from JhaSourav07/commitpulse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamplePreviewGraphs.test.ts
More file actions
40 lines (34 loc) · 1.61 KB
/
Copy pathsamplePreviewGraphs.test.ts
File metadata and controls
40 lines (34 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { describe, it, expect } from 'vitest';
import { SNAKE_SAMPLE_PREVIEW_SRC, PACMAN_SAMPLE_PREVIEW_SRC } from './samplePreviewGraphs';
describe('samplePreviewGraphs', () => {
it('SNAKE_SAMPLE_PREVIEW_SRC is a valid SVG data URI', () => {
expect(SNAKE_SAMPLE_PREVIEW_SRC).toMatch(/^data:image\/svg\+xml;charset=utf-8,/);
});
it('PACMAN_SAMPLE_PREVIEW_SRC is a valid SVG data URI', () => {
expect(PACMAN_SAMPLE_PREVIEW_SRC).toMatch(/^data:image\/svg\+xml;charset=utf-8,/);
});
it('decodes back into well-formed SVG markup for the snake preview', () => {
const decoded = decodeURIComponent(
SNAKE_SAMPLE_PREVIEW_SRC.replace('data:image/svg+xml;charset=utf-8,', '')
);
expect(decoded).toContain('<svg');
expect(decoded).toContain('</svg>');
expect(decoded).toContain('viewBox=');
});
it('decodes back into well-formed SVG markup for the pacman preview', () => {
const decoded = decodeURIComponent(
PACMAN_SAMPLE_PREVIEW_SRC.replace('data:image/svg+xml;charset=utf-8,', '')
);
expect(decoded).toContain('<svg');
expect(decoded).toContain('</svg>');
expect(decoded).toContain('<path'); // pacman mouth wedge
});
it('the two sample previews are different from each other', () => {
expect(SNAKE_SAMPLE_PREVIEW_SRC).not.toBe(PACMAN_SAMPLE_PREVIEW_SRC);
});
it('produces deterministic output (same module import, same string)', async () => {
const mod2 = await import('./samplePreviewGraphs');
expect(mod2.SNAKE_SAMPLE_PREVIEW_SRC).toBe(SNAKE_SAMPLE_PREVIEW_SRC);
expect(mod2.PACMAN_SAMPLE_PREVIEW_SRC).toBe(PACMAN_SAMPLE_PREVIEW_SRC);
});
});