• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / bento-icdc-frontend / 26519274266

27 May 2026 02:57PM UTC coverage: 17.458% (-8.3%) from 25.73%
26519274266

push

github

web-flow
Merge pull request #1606 from CBIIT/feature/ai-test-studio

core components unit test

306 of 2587 branches covered (11.83%)

Branch coverage included in aggregate %.

1 of 4244 new or added lines in 74 files covered. (0.02%)

2 existing lines in 2 files now uncovered.

2197 of 11750 relevant lines covered (18.7%)

0.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/components/Stats/utils.generated.test.js
1
// src/components/Stats/utils.test.js
2
import * as utils from './utils';
3

NEW
4
describe('humanFileSize', () => {
×
NEW
5
  test('returns empty string when input is undefined', () => {
×
NEW
6
    expect(utils.humanFileSize(undefined)).toBe('');
×
7
  });
8

NEW
9
  test('returns empty string when input is null', () => {
×
NEW
10
    expect(utils.humanFileSize(null)).toBe('');
×
11
  });
12

NEW
13
  test('returns empty string when input is a string', () => {
×
NEW
14
    expect(utils.humanFileSize('1024')).toBe('');
×
15
  });
16

NEW
17
  test('returns empty string when input is an object', () => {
×
NEW
18
    expect(utils.humanFileSize({})).toBe('');
×
19
  });
20

NEW
21
  test('returns 0 B when input is 0', () => {
×
NEW
22
    expect(utils.humanFileSize(0)).toBe('0 B');
×
23
  });
24

NEW
25
  test('returns bytes when size is less than 1024', () => {
×
NEW
26
    expect(utils.humanFileSize(1023)).toBe('1023 B');
×
27
  });
28

NEW
29
  test('returns 1 KB when input is 1024', () => {
×
NEW
30
    expect(utils.humanFileSize(1024)).toBe('1 KB');
×
31
  });
32

NEW
33
  test('formats KB values with up to two decimals', () => {
×
NEW
34
    expect(utils.humanFileSize(1536)).toBe('1.5 KB');
×
35
  });
36

NEW
37
  test('returns 1 MB for 1024^2', () => {
×
NEW
38
    expect(utils.humanFileSize(1024 ** 2)).toBe('1 MB');
×
39
  });
40

NEW
41
  test('returns 1 GB for 1024^3', () => {
×
NEW
42
    expect(utils.humanFileSize(1024 ** 3)).toBe('1 GB');
×
43
  });
44

NEW
45
  test('returns 1 TB for 1024^4', () => {
×
NEW
46
    expect(utils.humanFileSize(1024 ** 4)).toBe('1 TB');
×
47
  });
48

NEW
49
  test('returns NaN undefined for NaN input', () => {
×
NEW
50
    expect(utils.humanFileSize(NaN)).toBe('NaN undefined');
×
51
  });
52

NEW
53
  test('returns NaN undefined for negative numbers', () => {
×
NEW
54
    expect(utils.humanFileSize(-1)).toBe('NaN undefined');
×
55
  });
56

NEW
57
  test('returns 1 undefined for values beyond TB', () => {
×
NEW
58
    expect(utils.humanFileSize(1024 ** 5)).toBe('1 undefined');
×
59
  });
60
});
61

NEW
62
describe('updateStat', () => {
×
NEW
63
  test('subtracts study files from total files and formats volumeOfData', () => {
×
NEW
64
    const input = {
×
65
      numberOfStudyFiles: 5,
66
      numberOfFiles: 20,
67
      volumeOfData: 1024 ** 2,
68
      otherField: 'keep-me',
69
    };
70

NEW
71
    const result = utils.updateStat(input);
×
72

NEW
73
    expect(result).not.toBe(input);
×
NEW
74
    expect(result.numberOfFiles).toBe(15);
×
NEW
75
    expect(result.volumeOfData).toBe('1 MB');
×
NEW
76
    expect(result.otherField).toBe('keep-me');
×
NEW
77
    expect(input.numberOfFiles).toBe(20);
×
NEW
78
    expect(input.volumeOfData).toBe(1024 ** 2);
×
79
  });
80

NEW
81
  test('clamps numberOfFiles to 0 when subtraction is negative', () => {
×
NEW
82
    const input = {
×
83
      numberOfStudyFiles: 10,
84
      numberOfFiles: 3,
85
      volumeOfData: 0,
86
    };
87

NEW
88
    const result = utils.updateStat(input);
×
89

NEW
90
    expect(result.numberOfFiles).toBe(0);
×
NEW
91
    expect(result.volumeOfData).toBe('0 B');
×
92
  });
93

NEW
94
  test('sets numberOfFiles to 0 when counts are equal', () => {
×
NEW
95
    const input = {
×
96
      numberOfStudyFiles: 7,
97
      numberOfFiles: 7,
98
      volumeOfData: 1536,
99
    };
100

NEW
101
    const result = utils.updateStat(input);
×
102

NEW
103
    expect(result.numberOfFiles).toBe(0);
×
NEW
104
    expect(result.volumeOfData).toBe('1.5 KB');
×
105
  });
106

NEW
107
  test('formats volumeOfData using humanFileSize', () => {
×
NEW
108
    const input = {
×
109
      numberOfStudyFiles: 1,
110
      numberOfFiles: 2,
111
      volumeOfData: 1024,
112
    };
113

NEW
114
    const result = utils.updateStat(input);
×
115

NEW
116
    expect(result.volumeOfData).toBe('1 KB');
×
NEW
117
    expect(result.numberOfFiles).toBe(1);
×
118
  });
119

NEW
120
  test('handles missing properties by defaulting to 0 files and empty volume string', () => {
×
NEW
121
    const result = utils.updateStat({});
×
122

NEW
123
    expect(result.numberOfFiles).toBe(0);
×
NEW
124
    expect(result.volumeOfData).toBe('');
×
125
  });
126

NEW
127
  test('throws TypeError when stat is undefined', () => {
×
NEW
128
    expect(() => utils.updateStat(undefined)).toThrow(TypeError);
×
129
  });
130

NEW
131
  test('throws TypeError when stat is null', () => {
×
NEW
132
    expect(() => utils.updateStat(null)).toThrow(TypeError);
×
133
  });
134
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc