Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #193856

Merged
merged 1 commit into from
Sep 24, 2023
Merged

Add tests #193856

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ suite('Preferences Validation', () => {
urls.rejects('hellohel').withMessage('err: must be friendly');
urls.accepts('hellohello');
}
{
const unicodePattern = new Tester({ type: 'string', pattern: '^[\\p{L}\\d_. -]*$', minLength: 3 });
unicodePattern.accepts('_autoload');
unicodePattern.rejects('#hash');
unicodePattern.rejects('');
}
});

test('custom error messages are shown', () => {
Expand Down Expand Up @@ -437,6 +443,13 @@ suite('Preferences Validation', () => {
arr.rejects(['a']).withMessage(`Value 'a' must match regex`);
});

test('Unicode pattern', () => {
const arr = new ArrayTester({ type: 'array', items: { type: 'string', pattern: '^[\\p{L}\\d_. -]*$' } });

arr.accepts(['hello', 'world']);
arr.rejects(['hello', '#world']).withMessage(`Value '#world' must match regex`);
});

test('pattern with error message', () => {
const arr = new ArrayTester({ type: 'array', items: { type: 'string', pattern: '^(hello)*$', patternErrorMessage: 'err: must be friendly' } });

Expand Down