mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix iOS 12 crashing in scroller
This commit is contained in:
parent
b6745dcfbb
commit
7607c8dbd3
3 changed files with 49 additions and 15 deletions
42
src/utils/string.test.ts
Normal file
42
src/utils/string.test.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { toBoolean, toFloat } from './string';
|
||||
|
||||
describe('toBoolean', () => {
|
||||
it('Should return the boolean represented by the string', () => {
|
||||
let bool = toBoolean('true');
|
||||
expect(bool).toBe(true);
|
||||
|
||||
bool = toBoolean('false', true);
|
||||
expect(bool).toBe(false);
|
||||
});
|
||||
|
||||
it('Should return default value for invalid values', () => {
|
||||
let bool = toBoolean('test');
|
||||
expect(bool).toBe(false);
|
||||
|
||||
bool = toBoolean(undefined);
|
||||
expect(bool).toBe(false);
|
||||
|
||||
bool = toBoolean(null, true);
|
||||
expect(bool).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toFloat()', () => {
|
||||
it('Should return a float', () => {
|
||||
const number = toFloat('3.14159');
|
||||
expect(number).toBe(3.14159);
|
||||
});
|
||||
|
||||
it('Should return default value for NaN', () => {
|
||||
let number = toFloat('test');
|
||||
expect(number).toBe(0);
|
||||
|
||||
number = toFloat(undefined);
|
||||
expect(number).toBe(0);
|
||||
|
||||
number = toFloat(null, -1);
|
||||
expect(number).toBe(-1);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue