-
-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add snapshot test for all locales' character sets #3276
base: next
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #3276 +/- ##
=======================================
Coverage 99.96% 99.97%
=======================================
Files 2806 2806
Lines 217076 217076
Branches 968 971 +3
=======================================
+ Hits 217003 217018 +15
+ Misses 73 58 -15 |
"uz_UZ_latin": " #',-.ABCDEFGHIJKLMNOPQRSTUVWXYZ[\`abcdefghijklmnopqrstuvwxyz‘’", | ||
"vi": " #+-.ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyzÁÂÚÝàáâãèéêìíòóôõùúýăĐđĩũơưạẢảẤấầẨẩẫậắằẵặẽếềểễệỉịọỏốồổỗộớờởợụủứừửữựỳỷỹ", | ||
"yo_NG": "ABDEFGIJKLMNOPRSTWYabdefghijklmnoprstuwy", | ||
"zh_CN": " #()+-./ABCDEGHIJKLMOPQRSTUXYZabcdefghiklmnopqrstuvwxyz·【】一丁七万三上下不与丑专世丘丙业丛东丝严个中丰串丹为主丽举久么义之乌乎乐乔乘乙乜九也习乡书买乳乾了事二于亏云互亓五井亚些亢亥产亨享京亭人什仁仅仆仇仉介仍从仔付仙仝代令以仪们仰仲仵任份仿企伊伍伏休众优会伟传伤伦伯似但位体何佘余佛作佟你佩佳佴佼使侍依侠侨侬侯侵便俄俊俎保俞俟信修倒倘候倡倩倪偏做健偶傅储像僧僪儒儿允元充兆光克党入全八公六兰共关兴兵其具典兹养冀内冉再冒冗写军农冠冯况冶冷冻冼净凌凝几凤凭凯凰出击函刀刁分切刑列刘刚创初利别到制刷前剑剧剪劈力办功加务动助努励劳势勇勒勤勾包化北匠匡区十千半华协卑卓单南博卜卞占卡卢卧卫卯印危却卷卿历厉压厍厚原厦去县及友双反发叔取受叠口古只召可台史叶号司吃合吉同名后吐向吕君吞听吮启吴吸吾呈告员周味呼咀和咎咬咸哀品哈哥哪哭哲唐唱啃商啸喀善喇喜喝喷喻嘉嘻器嚼四回因团园固国图圆土圣在圭地圳场坎坏坐坚坞坡坦埃城培基堂堕堡堪堵塑塔塞境墙墨壕士壬壮声备复夏夔夕外夙多夜大天太夫头夷奇奈奉契奔奕套奚奢奥女奶她好如妄妈妍妫姆始姒姓委姚姜姬威娄娇娜娟婆婷媒嬴子孔字存孙孛孝孟季孤学孩宁宅宇守安宋完宏宓宗官定宛宜宝实客宣宦宫宰家宸容宽宾宿密寇富寒察寸寻导寿封将尉小少尔尘尚尝尤尧就尹尼尽尾局居屈屋屏展属屠山岁岑岗岛岩岳岸峻崇崔嵇川州巡巢工左巧巨巩巫差己已巴巷巾币市布帅师希帕帖帛带席常帽幕干平年幸幽广庄庆序库应底店庚府庞废度座康庹庾廉廊廖延廷建开式弓引弗弘张弥弦弧弭弹强归当彤彩彪彬彭影很律徐徒得御徭微德徽心必忆忍志忙忠快念忻怀态思怡性总恒恩恭恽悉悟悦悬悲情惟惠想愈意愚感慈慎慕慢慧懒懿戈戊戎戏成我战戚戢戴户房所扈手才打扔托扬扭扶承技抄把抓投抗折抚抛报披抬抱抽抿拆拉拍拎拔拖招拜拟拣拧拨拱拼拿持按挑挖挡挥挪振捉捏捡捣捧据捶捷捺掀掌掐排掘接控推掷揍提插握揭揽搀搁搂搔搜搡携摄摇摊摔摘摩摸撑撒撕撞撬播擅操擎擒擦攥支收改放政敏敖教敛敢敦敬数敲整文斋斌斐斗料斛断斯新方於施旁旅族旗无日旦旧旭时旷昂昆昊昌明易昔昕昝星春是显晁晋晏晓晚晟晨普景晴晶智暖暗暨暴暹曲更曹曼曾最月有朋服朗望期木未末本术朱朴机杂权杉李材村杜杞束条来杨杭杰松板极析林枚果枝枪枫柏柔柠查柯柳柴标栈栋树栗校根格栾桂桃桌桐桑桓桥梁梅梓梗梦梭械检棉棕森椅植楚楠楷楼概榕樊樟模橘橙橡檀次欣欧款歌止正此步武歧殇殳段殷毅毋母毓比毕毛氏民气氖氙氟氡氢氦氧氩氪氮氯水永求汉汐汗汝汞江池汤汪汲汽沃沈沐沙没沫河油治泉法泡波泣泥注泪泰泷泽洁洋洛津洪洲活流浅济浑浙浦浩浪浮海涂涛液涵淋淡淦深淳混淼清渊渐渠温港游湖湛湾源溜溥溪溴溺滑滕滚满漆演漫潇潘潜潭潮澄澳澹濮濯瀚火灯灰灵炎炫炬点烈烟烧烨热焉焦焱然煊煜照熊熙熟熠燃燕爬爱爵父爷片版牌牙牛牟牢牧物牵特犁犬状犹狂狄狐狗独狮狸猎猛猫献獒獚玄玉王玛玥玩玫环现玲玳玻珀珈珊珍珠班球理琦琪琴瑁瑚瑜瑞瑰瑶瑾璩瓜瓦瓮瓷甄甘甜生用甫田由甲申电男画畅界畔留略疆疏痣癸登白百皂的皇皋皓皮盈益盍监盒盖盘盛目直相省真眭眼睢督睦睫睿瞿知矩矫短石矶矿码砂破砷砹硅硒硕硫硬硼碌碎碘碧碲碳磊磨磷示礼祁祈祖祝神祢祥票祭祺禄福禚禹离禽禾秀秋种科秒秘秦称移程稍税稻稽穆穰空穿突窦立竞章童竭端竹竺笃笑笔符笪第等答简箕算管箱籍米类粉粗粘粟精糜系素索紫累綦繁红约级纪纲纳纵纽线练组细终绍经绒绕给络绝统绪续绳维绿缑编缩缪网罕罗羊美羽羿翁翊翟翠翦翰耀老考者耳耶耿聂聊联聪肃肇肉肖肠股肥肯育背胡胤胥胭胶能脂脆脑脱腓腾臧自至致舍舒舜舞航般舰良色艳艺艾节芒芝芬芮芯花芳芽苌苍苏苑苗苟苡若苦英苹茂范茅茆茗茶茹荀荆草荣荤荷莎莘莫莱获莽菅菊菱菲萄萍营萧萨萱葛葡董蒂蒉蒋蒙蒯蒲蒿蓄蓝蓟蓬蔚蔡蔺薄薛薯藏藤藩虎虚虞虢虹蚁蛮蝴蝶融蠕血衅行街衡衣表衫衬衷袁袖袭裂装裔裘裤裴褐褒褚西要覃覆见视觉解触言訾詹謇警计认让议记许设识试诗诚话该语说诸诺课调谈谌谏谢谣谬谭谯谷豆象豪豹貊贝贡责货质贯贰贲贵贷贸费贺贼贾资赏赖赛赠赤赧赫走赵起超越足跑跨路跳蹇蹉身车轨轩转轮软轻载轿较辅辉辑输辕辛辜辟辰边辽达过迈运还进远连迟迦迪迮迷迹退送适逄选逊逐途通速造逢逮逯遇道邓邗邛邝邢那邬邮邰邱邴邵邶邸邹郁郎郏郑郗郜郝郦部郭郯郸都鄂鄞鄢酆酋配酒酪酷释里重野量金鑫钆钇针钊钋钍钐钒钔钕钙钚钛钞钟钠钡钢钦钨钪钫钬钭钮钯钰钱钴钷钼钽钾钿铁铂铃铅铈铊铋铌铍铎铕铜铝铟铥铪铬铯铱银铷铹铼铽链锁锂锆锇锋锌锎锐锑锔锕锗锘错锝锡锦锫键锰锶锺锿镁镄镅镆镇镉镍镎镓镜镥镧镨镭镱长门闪闫闭问闳间闵闻闽闾阎阙阚阮防阳阴阵阿陀际陆陈限陕险陶隆隋随隐隗隽难雀雄雅集雍雨雪雯零雷雾需霍霖霜霞青靖静靛非面革靳鞋鞠韦韩韬音韶页项须顾顿领频颖题颜风飘飞食饶首香馥馨马驰驱驶驹驾骆骑骞骨高魂魏鱼鲁鲍鲜鲟鲤鲫鲶鳙鸡鸿鹏鹤鹭鹰鹿麦麴麻黄黎黑默鼠齐齿龙龚鿏鿔鿫鿭𫓧𫟷𫟼𬬭𬬻𬭊𬭛𬭳𬭶!(),", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about testing these languages, as they have a lot of entries...
/** | ||
* A set of locale data paths that should be ignored when checking for characters. | ||
* Because these usually contain data using Latin characters that are otherwise not relevant to the locale. | ||
*/ | ||
const ignoredCharacterData = new Set([ | ||
'.airline.airline[].iataCode', | ||
'.airline.airplane[].iataTypeCode', | ||
'.airline.airport[].iataCode', | ||
'.finance.currency', | ||
'.finance.credit_card', | ||
'.hacker.abbreviation', | ||
'.internet.domain_suffix', | ||
'.internet.emoji', | ||
'.internet.example_email', | ||
'.internet.free_email', | ||
'.location.country_code', | ||
'.metadata', | ||
'.science.chemical_element[].symbol', | ||
'.science.unit[].symbol', | ||
'.system.directory_path', | ||
'.system.mime_type', | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether I try to do something too fancy here.
This mostly reduces A-Z and a-z in non-latin based languages.
data | ||
.replaceAll(/{{(?:[^{]|{(?!{))*?}}/g, '') // remove placeholders | ||
.replaceAll(/\d+/g, '') // remove numbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
/** | ||
* Helper function to locate a specific character in the locale data. | ||
* | ||
* @param data The locale data to search in. | ||
* @param char The character to search for. | ||
* @param path The current path in the data. Defaults to an empty string. | ||
* | ||
* @example | ||
* locateCharacter(allLocales.zh_CN, 'A'); | ||
*/ | ||
export function locateCharacter( | ||
data: unknown, | ||
char: string, | ||
path: string = '' | ||
): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this helpful enough to be included in here for testing purposes?
Fixes #1934
Adds a snapshot test that checks which characters are used by a locale.