11import { calculateTaskStorageSize } from "../task-storage-size"
2- import { formatBytes } from "../formatBytes"
32
43// Mock storage to avoid VS Code config access during tests
54vi . mock ( "../storage" , ( ) => ( {
@@ -13,44 +12,6 @@ vi.mock("fs/promises", () => ({
1312 readdir : ( ...args : unknown [ ] ) => mockReaddir ( ...args ) ,
1413} ) )
1514
16- describe ( "formatBytes" , ( ) => {
17- it ( "should format 0 bytes" , ( ) => {
18- expect ( formatBytes ( 0 ) ) . toBe ( "0 B" )
19- } )
20-
21- it ( "should format bytes less than 1 KB" , ( ) => {
22- expect ( formatBytes ( 512 ) ) . toBe ( "512 B" )
23- expect ( formatBytes ( 1 ) ) . toBe ( "1 B" )
24- } )
25-
26- it ( "should format kilobytes (0 decimal places)" , ( ) => {
27- expect ( formatBytes ( 1024 ) ) . toBe ( "1 KB" )
28- expect ( formatBytes ( 2048 ) ) . toBe ( "2 KB" )
29- expect ( formatBytes ( 1536 ) ) . toBe ( "2 KB" ) // Rounds to nearest integer
30- expect ( formatBytes ( 1280 ) ) . toBe ( "1 KB" ) // Rounds down
31- } )
32-
33- it ( "should format megabytes (2 decimal places)" , ( ) => {
34- expect ( formatBytes ( 1048576 ) ) . toBe ( "1.00 MB" )
35- expect ( formatBytes ( 1572864 ) ) . toBe ( "1.50 MB" )
36- expect ( formatBytes ( 10485760 ) ) . toBe ( "10.00 MB" )
37- } )
38-
39- it ( "should format gigabytes (2 decimal places)" , ( ) => {
40- expect ( formatBytes ( 1073741824 ) ) . toBe ( "1.00 GB" )
41- expect ( formatBytes ( 2147483648 ) ) . toBe ( "2.00 GB" )
42- } )
43-
44- it ( "should format terabytes (2 decimal places)" , ( ) => {
45- expect ( formatBytes ( 1099511627776 ) ) . toBe ( "1.00 TB" )
46- } )
47-
48- it ( "should handle decimal precision correctly" , ( ) => {
49- expect ( formatBytes ( 1234567 ) ) . toBe ( "1.18 MB" )
50- expect ( formatBytes ( 123456789 ) ) . toBe ( "117.74 MB" )
51- } )
52- } )
53-
5415describe ( "calculateTaskStorageSize" , ( ) => {
5516 beforeEach ( ( ) => {
5617 vi . clearAllMocks ( )
0 commit comments