Skip to content

Commit f8062de

Browse files
committed
test: restore original calculation behavior
1 parent c7c66a6 commit f8062de

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

app/composables/useNumberFormatter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export const useBytesFormatter = () => {
1616
const decimalNumberFormatter = useNumberFormatter({
1717
maximumFractionDigits: 1,
1818
})
19-
const KB = 1024
20-
const MB = 1024 * 1024
19+
const KB = 1000
20+
const MB = 1000 * 1000
2121

2222
return {
2323
format: (bytes: number) => {

test/unit/app/composables/use-number-formatter.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ describe('useBytesFormatter', () => {
3030
expect(format(999)).toBe('999 B')
3131
})
3232

33-
it('formats kB values using decimal base (1024)', () => {
33+
it('formats kB values using decimal base (1000)', () => {
3434
const { format } = useBytesFormatter()
3535

36-
expect(format(1024)).toBe('1 kB')
37-
expect(format(8704)).toBe('8.5 kB')
36+
expect(format(1000)).toBe('1 kB')
37+
expect(format(8414)).toBe('8.4 kB')
3838
})
3939

40-
it('formats MB values using decimal base (1024 * 1024)', () => {
40+
it('formats MB values using decimal base (1000 * 1000)', () => {
4141
const { format } = useBytesFormatter()
4242

43-
expect(format(1_048_576)).toBe('1 MB')
44-
expect(format(1_572_864)).toBe('1.5 MB')
43+
expect(format(1_000_000)).toBe('1 MB')
44+
expect(format(1_500_000)).toBe('1.5 MB')
4545
})
4646
})

0 commit comments

Comments
 (0)