Repository navigation
Expand file tree
/
Copy pathgithub.empty-fallback.test.ts
More file actions
74 lines (64 loc) · 1.77 KB
/
Copy pathgithub.empty-fallback.test.ts
File metadata and controls
74 lines (64 loc) · 1.77 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { describe, it, expect } from 'vitest';
import {
aggregateLanguages,
buildActivityMap,
buildInsights,
buildProfileData,
computeDeveloperScore,
} from './github';
describe('GitHub Empty Fallback Verification', () => {
it('renders safe fallback profile values when optional fields are missing', () => {
const profile = buildProfileData(
{
login: 'octocat',
name: null,
avatar_url: '',
public_repos: 0,
followers: 0,
following: 0,
created_at: '2024-01-01T00:00:00Z',
bio: null,
location: null,
plan: null,
},
0,
0
);
expect(profile.name).toBe('octocat');
expect(profile.bio).toBe('No bio available');
expect(profile.location).toBe('Earth');
expect(profile.isPro).toBe(false);
});
it('returns empty language collection when repo list is empty', () => {
const result = aggregateLanguages([]);
expect(result).toEqual([]);
expect(result).toHaveLength(0);
});
it('returns safe insight cards when language data is missing', () => {
const insights = buildInsights(
{
totalContributions: 0,
currentStreak: 0,
longestStreak: 0,
},
[]
);
expect(insights).toHaveLength(3);
expect(insights[1].text).toContain('Unknown');
});
it('returns empty activity map when contribution days are missing', () => {
const result = buildActivityMap([]);
expect(result).toEqual([]);
expect(result).toHaveLength(0);
});
it('returns zero developer score for completely empty activity metrics', () => {
const score = computeDeveloperScore({
repos: 0,
followers: 0,
stars: 0,
contributions: 0,
longestStreak: 0,
});
expect(score).toBe(0);
});
});