mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-27 12:55:20 -07:00
18 lines
792 B
TypeScript
18 lines
792 B
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { parseOptionalNumberInputValue } from './input-values';
|
|
|
|
test('parseOptionalNumberInputValue treats empty input as unset', () => {
|
|
assert.deepEqual(parseOptionalNumberInputValue(''), { ok: true, value: undefined });
|
|
assert.deepEqual(parseOptionalNumberInputValue(' '), { ok: true, value: undefined });
|
|
});
|
|
|
|
test('parseOptionalNumberInputValue parses finite numeric input', () => {
|
|
assert.deepEqual(parseOptionalNumberInputValue('42'), { ok: true, value: 42 });
|
|
assert.deepEqual(parseOptionalNumberInputValue(' 3.5 '), { ok: true, value: 3.5 });
|
|
});
|
|
|
|
test('parseOptionalNumberInputValue rejects invalid numeric input', () => {
|
|
assert.deepEqual(parseOptionalNumberInputValue('abc'), { ok: false });
|
|
});
|