wip: code formatting nits continued

This commit is contained in:
jdalton
2023-09-16 22:59:56 -07:00
parent 0b28b7f7b6
commit b5c59317ea
421 changed files with 7354 additions and 9005 deletions

27
test/escapeRegExp.spec.js Normal file
View File

@@ -0,0 +1,27 @@
import lodashStable from 'lodash';
import { stubString } from './utils';
import escapeRegExp from '../src/escapeRegExp';
describe('escapeRegExp', () => {
const escaped = '\\^\\$\\.\\*\\+\\?\\(\\)\\[\\]\\{\\}\\|\\\\';
const unescaped = '^$.*+?()[]{}|\\';
it('should escape values', () => {
expect(escapeRegExp(unescaped + unescaped)).toBe(escaped + escaped);
});
it('should handle strings with nothing to escape', () => {
expect(escapeRegExp('abc')).toBe('abc');
});
it('should return an empty string for empty values', () => {
const values = [, null, undefined, ''];
const expected = lodashStable.map(values, stubString);
const actual = lodashStable.map(values, (value, index) =>
index ? escapeRegExp(value) : escapeRegExp(),
);
expect(actual).toEqual(expected);
});
});