aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/locale-proxy.ts8
-rw-r--r--test/locale-proxy.spec.ts10
2 files changed, 17 insertions, 1 deletions
diff --git a/src/locale-proxy.ts b/src/locale-proxy.ts
index c5c6aa1b..ae5ede17 100644
--- a/src/locale-proxy.ts
+++ b/src/locale-proxy.ts
@@ -31,6 +31,10 @@ export function createLocaleProxy(locale: LocaleDefinition): LocaleProxy {
target: LocaleDefinition,
categoryName: keyof LocaleDefinition
): LocaleDefinition[keyof LocaleDefinition] {
+ if (typeof categoryName === 'symbol' || categoryName === 'nodeType') {
+ return target[categoryName];
+ }
+
if (categoryName in proxies) {
return proxies[categoryName];
}
@@ -69,7 +73,9 @@ function createCategoryProxy<
entryName: keyof CategoryData
): CategoryData[keyof CategoryData] {
const value = target[entryName];
- if (value === null) {
+ if (typeof entryName === 'symbol' || entryName === 'nodeType') {
+ return value;
+ } else if (value === null) {
throw new FakerError(
`The locale data for '${categoryName}.${entryName.toString()}' aren't applicable to this locale.
If you think this is a bug, please report it at: https://github.com/faker-js/faker`
diff --git a/test/locale-proxy.spec.ts b/test/locale-proxy.spec.ts
index 88ce9555..fcb97e34 100644
--- a/test/locale-proxy.spec.ts
+++ b/test/locale-proxy.spec.ts
@@ -7,6 +7,16 @@ describe('LocaleProxy', () => {
const locale = createLocaleProxy(en);
const enAirline = en.airline ?? { never: 'missing' };
+ describe('locale', () => {
+ it('should be possible to use equals on locale', () => {
+ expect(locale).toEqual(createLocaleProxy(en));
+ });
+
+ it('should be possible to use not equals on locale', () => {
+ expect(locale).not.toEqual(createLocaleProxy({}));
+ });
+ });
+
describe('category', () => {
it('should be possible to check for a missing category', () => {
expect('category' in locale).toBe(true);