Rocket.Chat.ReactNative/app/lib/database/utils.test.ts

42 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as utils from './utils';
describe('sanitizeLikeStringTester', () => {
// example chars that shouldn't return
const disallowedChars = ',./;[]!@#$%^&*()_-=+~';
const sanitizeLikeStringTester = (str: string) =>
expect(utils.sanitizeLikeString(`${str}${disallowedChars}`)).toBe(`${str}${'_'.repeat(disallowedChars.length)}`);
test('render empty', () => {
expect(utils.sanitizeLikeString('')).toBe('');
expect(utils.sanitizeLikeString(undefined)).toBe(undefined);
});
// Testing a couple of different alphabets
test('render test (latin)', () => {
sanitizeLikeStringTester('test123');
});
test('render test (arabic)', () => {
sanitizeLikeStringTester('اختبار123');
});
test('render test (russian)', () => {
sanitizeLikeStringTester(ест123');
});
test('render test (chinese trad)', () => {
sanitizeLikeStringTester('測試123');
});
test('render test (japanese)', () => {
sanitizeLikeStringTester('テスト123');
});
});
describe('sanitizer', () => {
test('render the same result', () => {
const content = { a: true };
expect(utils.sanitizer(content)).toBe(content);
});
});