util: getInputNumber func

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2024-12-13 13:04:18 +01:00
parent ca8094202e
commit e6e545e60d
2 changed files with 33 additions and 0 deletions

View File

@@ -201,6 +201,31 @@ ccccccccc`,
});
});
describe('getInputNumber', () => {
it('should return a number when input is a valid number string', () => {
setInput('foo', '42');
const result = Util.getInputNumber('foo');
expect(result).toBe(42);
});
it('should return undefined when input is an empty string', () => {
setInput('foo', '');
const result = Util.getInputNumber('foo');
expect(result).toBeUndefined();
});
it('should return undefined when input is not provided', () => {
const result = Util.getInputNumber('foo');
expect(result).toBeUndefined();
});
it('should return NaN when input is not a valid number', () => {
setInput('foo', 'invalid');
const result = Util.getInputNumber('foo');
expect(result).toBeNaN();
});
});
describe('asyncForEach', () => {
it('executes async tasks sequentially', async () => {
const testValues = [1, 2, 3, 4, 5];