Delete assets/js/dashboard/stats/graph/main-graph-data.test.ts with huggingface_hub
Browse files
assets/js/dashboard/stats/graph/main-graph-data.test.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
| 1 |
-
import {
|
| 2 |
-
getChangeInPercentagePoints,
|
| 3 |
-
getRelativeChange,
|
| 4 |
-
getLineSegments
|
| 5 |
-
} from './main-graph-data'
|
| 6 |
-
|
| 7 |
-
describe(`${getChangeInPercentagePoints.name}`, () => {
|
| 8 |
-
it('returns the difference', () => {
|
| 9 |
-
expect(getChangeInPercentagePoints(70, 60)).toBe(10)
|
| 10 |
-
})
|
| 11 |
-
|
| 12 |
-
it('returns a negative value when value is lower', () => {
|
| 13 |
-
expect(getChangeInPercentagePoints(30, 50)).toBe(-20)
|
| 14 |
-
})
|
| 15 |
-
|
| 16 |
-
it('returns 0 when both values are equal', () => {
|
| 17 |
-
expect(getChangeInPercentagePoints(5, 5)).toBe(0)
|
| 18 |
-
})
|
| 19 |
-
})
|
| 20 |
-
|
| 21 |
-
describe(`${getRelativeChange.name}`, () => {
|
| 22 |
-
it('returns the percentage change rounded to nearest integer', () => {
|
| 23 |
-
expect(getRelativeChange(150, 100)).toBe(50)
|
| 24 |
-
})
|
| 25 |
-
|
| 26 |
-
it('rounds fractional percentages', () => {
|
| 27 |
-
expect(getRelativeChange(10, 3)).toBe(233) // (10-3)/3*100 = 233.33...
|
| 28 |
-
})
|
| 29 |
-
|
| 30 |
-
it('returns 100 when comparison is 0 and value is positive', () => {
|
| 31 |
-
expect(getRelativeChange(5, 0)).toBe(100)
|
| 32 |
-
})
|
| 33 |
-
|
| 34 |
-
it('returns 0 when both are 0', () => {
|
| 35 |
-
expect(getRelativeChange(0, 0)).toBe(0)
|
| 36 |
-
})
|
| 37 |
-
|
| 38 |
-
it('returns a negative value for a decrease', () => {
|
| 39 |
-
expect(getRelativeChange(50, 100)).toBe(-50)
|
| 40 |
-
})
|
| 41 |
-
})
|
| 42 |
-
|
| 43 |
-
const seriesValueBase = {
|
| 44 |
-
numericValue: 0,
|
| 45 |
-
value: 0,
|
| 46 |
-
timeLabel: ''
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
// not current
|
| 50 |
-
const nc = () => ({
|
| 51 |
-
isCurrent: false,
|
| 52 |
-
isPartial: false,
|
| 53 |
-
isDefined: true,
|
| 54 |
-
...seriesValueBase
|
| 55 |
-
})
|
| 56 |
-
// current
|
| 57 |
-
const c = () => ({
|
| 58 |
-
isCurrent: true,
|
| 59 |
-
isPartial: false,
|
| 60 |
-
isDefined: true,
|
| 61 |
-
...seriesValueBase
|
| 62 |
-
})
|
| 63 |
-
const gap = () => ({ isDefined: false }) as const
|
| 64 |
-
|
| 65 |
-
describe(`${getLineSegments.name}`, () => {
|
| 66 |
-
it('returns empty for empty input', () => {
|
| 67 |
-
expect(getLineSegments([])).toEqual([])
|
| 68 |
-
})
|
| 69 |
-
|
| 70 |
-
it('returns empty for a single point (no edge to draw)', () => {
|
| 71 |
-
expect(getLineSegments([nc()])).toEqual([])
|
| 72 |
-
})
|
| 73 |
-
|
| 74 |
-
it('returns empty for a single gap', () => {
|
| 75 |
-
expect(getLineSegments([gap()])).toEqual([])
|
| 76 |
-
})
|
| 77 |
-
|
| 78 |
-
it('returns a full segment for two points', () => {
|
| 79 |
-
expect(getLineSegments([nc(), nc()])).toEqual([
|
| 80 |
-
{ startIndexInclusive: 0, stopIndexExclusive: 2, type: 'full' }
|
| 81 |
-
])
|
| 82 |
-
})
|
| 83 |
-
|
| 84 |
-
it('returns a current segment when connecting to current point', () => {
|
| 85 |
-
expect(getLineSegments([nc(), c()])).toEqual([
|
| 86 |
-
{ startIndexInclusive: 0, stopIndexExclusive: 2, type: 'current' }
|
| 87 |
-
])
|
| 88 |
-
})
|
| 89 |
-
|
| 90 |
-
it('handles more points when the last point is current', () => {
|
| 91 |
-
expect(getLineSegments([nc(), nc(), nc(), c()])).toEqual([
|
| 92 |
-
{ startIndexInclusive: 0, stopIndexExclusive: 3, type: 'full' },
|
| 93 |
-
{ startIndexInclusive: 2, stopIndexExclusive: 4, type: 'current' }
|
| 94 |
-
])
|
| 95 |
-
})
|
| 96 |
-
|
| 97 |
-
it('handles leading gaps', () => {
|
| 98 |
-
expect(
|
| 99 |
-
getLineSegments([gap(), gap(), nc(), nc(), nc(), nc(), c()])
|
| 100 |
-
).toEqual([
|
| 101 |
-
{ startIndexInclusive: 2, stopIndexExclusive: 6, type: 'full' },
|
| 102 |
-
{ startIndexInclusive: 5, stopIndexExclusive: 7, type: 'current' }
|
| 103 |
-
])
|
| 104 |
-
})
|
| 105 |
-
|
| 106 |
-
it('handles trailing gaps', () => {
|
| 107 |
-
expect(getLineSegments([nc(), nc(), nc(), gap(), gap()])).toEqual([
|
| 108 |
-
{ startIndexInclusive: 0, stopIndexExclusive: 3, type: 'full' }
|
| 109 |
-
])
|
| 110 |
-
})
|
| 111 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|