文件
mynode/packages/app-mobile/components/screens/ConfigScreen/ValidatedIntegerInput.test.tsx
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

53 行
2.1 KiB
TypeScript

import { validate } from './ValidatedIntegerInput';
import Setting from '@joplin/lib/models/Setting';
describe('ValidatedIntegerInput', () => {
test.each(
['aaa', '1a1', '1a', '1.1', '1-1', '1-', '', null],
)('should return error message for invalid value or empty value for setting without range', async (input) => {
const md = Setting.settingMetadata('style.editor.contentMaxWidth');
const value = validate(input, md, md.label());
expect(value).toBe('Editor maximum width must be a valid whole number');
});
test.each(
['aaa', '1a1', '1a', '1.1', '1-1', '1-', '', null],
)('should return error message for invalid or empty value for setting with range', async (input) => {
const md = Setting.settingMetadata('revisionService.ttlDays');
const value = validate(input, md, md.label());
expect(value).toBe('Keep note history for must be a valid whole number');
});
test.each(
['0', '-1'],
)('should return error message for too low integer values', async (input) => {
const md = Setting.settingMetadata('revisionService.ttlDays');
const value = validate(input, md, md.label());
expect(value).toBe('Keep note history for cannot be less than 1');
});
test.each(
['100000', '1e20'],
)('should return error message for too high integer values', async (input) => {
const md = Setting.settingMetadata('revisionService.ttlDays');
const value = validate(input, md, md.label());
expect(value).toBe('Keep note history for cannot be greater than 99999');
});
test.each(
['-999999999999999', '0', '999999999999999', '0.0'],
)('should return empty string for valid integer values for setting without range', async (input) => {
const md = Setting.settingMetadata('style.editor.contentMaxWidth');
const value = validate(input, md, md.label());
expect(value).toBe('');
});
test.each(
['1', '300', '99999', '1.0'],
)('should return empty string for valid integer values for setting with range', async (input) => {
const md = Setting.settingMetadata('revisionService.ttlDays');
const value = validate(input, md, md.label());
expect(value).toBe('');
});
});