mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
wip: migrate to bun
This commit is contained in:
28
test/escapeRegExp.spec.ts
Normal file
28
test/escapeRegExp.spec.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import assert from 'node:assert';
|
||||
import lodashStable from 'lodash';
|
||||
import { stubString } from './utils';
|
||||
import escapeRegExp from '../src/escapeRegExp';
|
||||
|
||||
describe('escapeRegExp', () => {
|
||||
const escaped = '\\^\\$\\.\\*\\+\\?\\(\\)\\[\\]\\{\\}\\|\\\\',
|
||||
unescaped = '^$.*+?()[]{}|\\';
|
||||
|
||||
it('should escape values', () => {
|
||||
assert.strictEqual(escapeRegExp(unescaped + unescaped), escaped + escaped);
|
||||
});
|
||||
|
||||
it('should handle strings with nothing to escape', () => {
|
||||
assert.strictEqual(escapeRegExp('abc'), 'abc');
|
||||
});
|
||||
|
||||
it('should return an empty string for empty values', () => {
|
||||
const values = [, null, undefined, ''],
|
||||
expected = lodashStable.map(values, stubString);
|
||||
|
||||
const actual = lodashStable.map(values, (value, index) =>
|
||||
index ? escapeRegExp(value) : escapeRegExp(),
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user