mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-10 19:47:42 +00:00
fix(release): harden speed limits and extension replay checks
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { displayValueFromPresetBase, presetBaseFromDisplayValue } from './SpeedLimiterView';
|
||||
import {
|
||||
convertSpeedValue,
|
||||
displayValueFromPresetBase,
|
||||
presetBaseFromDisplayValue,
|
||||
} from './SpeedLimiterView';
|
||||
|
||||
describe('SpeedLimiterView speed conversions', () => {
|
||||
it('converts KB/s and MB/s using binary units consistently', () => {
|
||||
@@ -8,4 +12,12 @@ describe('SpeedLimiterView speed conversions', () => {
|
||||
expect(presetBaseFromDisplayValue(5, 'MB/s')).toBe(5);
|
||||
expect(displayValueFromPresetBase(5, 'MB/s')).toBe(5);
|
||||
});
|
||||
|
||||
it('round-trips non-MiB-aligned presets through the integer KiB backend value', () => {
|
||||
const presetBase = presetBaseFromDisplayValue(1500, 'KB/s');
|
||||
|
||||
expect(displayValueFromPresetBase(presetBase, 'KB/s')).toBe(1500);
|
||||
expect(convertSpeedValue(1500, 'KB/s', 'MB/s')).toBe(1500 / 1024);
|
||||
expect(convertSpeedValue(convertSpeedValue(1500, 'KB/s', 'MB/s'), 'MB/s', 'KB/s')).toBe(1500);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user