FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
aRustyDev/readme/fetch-github.test.ts at main · aRustyDev/aRustyDev · GitHub
aRustyDev
/
aRustyDev
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
31
Pull requests
10
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
aRustyDev
/
readme
/
fetch-github.test.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (44 loc) · 1.49 KB
Breadcrumbs
aRustyDev
/
readme
/
fetch-github.test.ts
Copy path
File metadata and controls
50 lines (44 loc) · 1.49 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
{
describe
,
it
,
expect
}
from
"vitest"
;
import
{
processLanguageData
,
processContributions
}
from
"./fetch-github.js"
;
describe
(
"processLanguageData"
,
(
)
=>
{
it
(
"calculates percentages and sorts by bytes descending"
,
(
)
=>
{
const
raw
=
{
TypeScript
:
{
bytes
:
50000
,
color
:
"#3178c6"
}
,
Rust
:
{
bytes
:
30000
,
color
:
"#dea584"
}
,
Shell
:
{
bytes
:
20000
,
color
:
"#89e051"
}
,
}
;
const
result
=
processLanguageData
(
raw
)
;
expect
(
result
)
.
toHaveLength
(
3
)
;
expect
(
result
[
0
]
.
name
)
.
toBe
(
"TypeScript"
)
;
expect
(
result
[
0
]
.
percentage
)
.
toBe
(
50
)
;
expect
(
result
[
1
]
.
name
)
.
toBe
(
"Rust"
)
;
expect
(
result
[
1
]
.
percentage
)
.
toBe
(
30
)
;
expect
(
result
[
2
]
.
name
)
.
toBe
(
"Shell"
)
;
expect
(
result
[
2
]
.
percentage
)
.
toBe
(
20
)
;
}
)
;
it
(
"returns empty array for empty input"
,
(
)
=>
{
expect
(
processLanguageData
(
{
}
)
)
.
toEqual
(
[
]
)
;
}
)
;
}
)
;
describe
(
"processContributions"
,
(
)
=>
{
it
(
"aggregates daily contributions into weekly buckets"
,
(
)
=>
{
const
weeks
=
[
{
contributionDays
:
[
{
date
:
"2026-01-05"
,
contributionCount
:
3
}
,
{
date
:
"2026-01-06"
,
contributionCount
:
5
}
,
{
date
:
"2026-01-07"
,
contributionCount
:
0
}
,
]
,
}
,
{
contributionDays
:
[
{
date
:
"2026-01-12"
,
contributionCount
:
2
}
,
]
,
}
,
]
;
const
result
=
processContributions
(
weeks
)
;
expect
(
result
)
.
toHaveLength
(
2
)
;
expect
(
result
[
0
]
.
count
)
.
toBe
(
8
)
;
// 3+5+0
expect
(
result
[
1
]
.
count
)
.
toBe
(
2
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL