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

37
test/isRegExp.spec.js Normal file
View File

@@ -0,0 +1,37 @@
import lodashStable from 'lodash';
import { falsey, stubFalse, args, slice, symbol, realm } from './utils';
import isRegExp from '../src/isRegExp';
describe('isRegExp', () => {
it('should return `true` for regexes', () => {
expect(isRegExp(/x/)).toBe(true);
expect(isRegExp(RegExp('x'))).toBe(true);
});
it('should return `false` for non-regexes', () => {
const expected = lodashStable.map(falsey, stubFalse);
const actual = lodashStable.map(falsey, (value, index) =>
index ? isRegExp(value) : isRegExp(),
);
expect(actual).toEqual(expected);
expect(isRegExp(args)).toBe(false);
expect(isRegExp([1, 2, 3])).toBe(false);
expect(isRegExp(true)).toBe(false);
expect(isRegExp(new Date())).toBe(false);
expect(isRegExp(new Error())).toBe(false);
expect(isRegExp(slice)).toBe(false);
expect(isRegExp({ a: 1 })).toBe(false);
expect(isRegExp(1)).toBe(false);
expect(isRegExp('a')).toBe(false);
expect(isRegExp(symbol)).toBe(false);
});
it('should work with regexes from another realm', () => {
if (realm.regexp) {
expect(isRegExp(realm.regexp)).toBe(true);
}
});
});