File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ export function createLocaleProxy(locale: LocaleDefinition): LocaleProxy {
3131 target : LocaleDefinition ,
3232 categoryName : keyof LocaleDefinition
3333 ) : LocaleDefinition [ keyof LocaleDefinition ] {
34+ if ( typeof categoryName === 'symbol' || categoryName === 'nodeType' ) {
35+ return target [ categoryName ] ;
36+ }
37+
3438 if ( categoryName in proxies ) {
3539 return proxies [ categoryName ] ;
3640 }
@@ -69,7 +73,9 @@ function createCategoryProxy<
6973 entryName : keyof CategoryData
7074 ) : CategoryData [ keyof CategoryData ] {
7175 const value = target [ entryName ] ;
72- if ( value === null ) {
76+ if ( typeof entryName === 'symbol' || entryName === 'nodeType' ) {
77+ return value ;
78+ } else if ( value === null ) {
7379 throw new FakerError (
7480 `The locale data for '${ categoryName } .${ entryName . toString ( ) } ' aren't applicable to this locale.
7581 If you think this is a bug, please report it at: https://github.com/faker-js/faker`
Original file line number Diff line number Diff line change @@ -7,6 +7,16 @@ describe('LocaleProxy', () => {
77 const locale = createLocaleProxy ( en ) ;
88 const enAirline = en . airline ?? { never : 'missing' } ;
99
10+ describe ( 'locale' , ( ) => {
11+ it ( 'should be possible to use equals on locale' , ( ) => {
12+ expect ( locale ) . toEqual ( createLocaleProxy ( en ) ) ;
13+ } ) ;
14+
15+ it ( 'should be possible to use not equals on locale' , ( ) => {
16+ expect ( locale ) . not . toEqual ( createLocaleProxy ( { } ) ) ;
17+ } ) ;
18+ } ) ;
19+
1020 describe ( 'category' , ( ) => {
1121 it ( 'should be possible to check for a missing category' , ( ) => {
1222 expect ( 'category' in locale ) . toBe ( true ) ;
You can’t perform that action at this time.
0 commit comments