11import { z } from "zod" ;
2- import bundledSmileys from "../bundled-json-files/emoji-test-smileys.json" ;
2+ import bundledFlags from "../bundled-json-files/emoji-test-flags.json" with { type : "json" } ;
3+ import bundledSmileys from "../bundled-json-files/emoji-test-smileys.json" with { type : "json" } ;
34import { createLoom } from "../loom" ;
45
6+ const VALID_STATUS = [
7+ "component" ,
8+ "fully-qualified" ,
9+ "minimally-qualified" ,
10+ "unqualified" ,
11+ ] as const ;
12+
513const entry = z . object ( {
614 codePoints : z . array ( z . string ( ) ) ,
7- status : z . union ( [
8- z . literal ( "component" ) ,
9- z . literal ( "fully-qualified" ) ,
10- z . literal ( "minimally-qualified" ) ,
11- z . literal ( "unqualified" ) ,
12- ] ) ,
15+ // can't use union of literals since typescript can only infer
16+ // the status type to a string, and not the union of literals
17+ status : z . string ( ) . refine (
18+ ( val ) => VALID_STATUS . includes ( val as ( typeof VALID_STATUS ) [ number ] ) ,
19+ {
20+ message : `status must be one of: ${ VALID_STATUS . join ( ", " ) } ` ,
21+ } ,
22+ ) ,
1323 comment : z . string ( ) ,
1424} ) ;
1525
@@ -27,7 +37,7 @@ const emojiTestOptionsSchema = z.object({
2737 version : z . string ( ) ,
2838} ) ;
2939
30- const baseEmojiTest = createLoom ( {
40+ export const emojiTest = createLoom ( {
3141 inputSchema : emojiTestInputSchema ,
3242 optionsSchema : emojiTestOptionsSchema ,
3343 predicate : ( ctx ) => {
@@ -48,129 +58,8 @@ const baseEmojiTest = createLoom({
4858
4959 return template ;
5060 } ,
51- } ) ;
52-
53- export const emojiTest = Object . assign ( baseEmojiTest , {
54- smileys : ( version : string ) : string => {
55- return baseEmojiTest ( {
56- version,
57- separator : ";" ,
58- commentPrefix : "#" ,
59- // @ts -expect-error asd
60- input : bundledSmileys ,
61- } ) ;
62- } ,
63- skinTone : ( version : string ) : string => {
64- return baseEmojiTest ( {
65- version,
66- separator : ";" ,
67- commentPrefix : "#" ,
68- input : [
69- {
70- group : "Component" ,
71- subgroups : [
72- {
73- subgroup : "skin-tone" ,
74- entries : [
75- {
76- codePoints : [ "1F3FB" ] ,
77- status : "component" ,
78- comment : "light skin tone" ,
79- } ,
80- {
81- codePoints : [ "1F3FC" ] ,
82- status : "component" ,
83- comment : "medium-light skin tone" ,
84- } ,
85- {
86- codePoints : [ "1F3FD" ] ,
87- status : "component" ,
88- comment : "medium skin tone" ,
89- } ,
90- {
91- codePoints : [ "1F3FE" ] ,
92- status : "component" ,
93- comment : "medium-dark skin tone" ,
94- } ,
95- {
96- codePoints : [ "1F3FF" ] ,
97- status : "component" ,
98- comment : "dark skin tone" ,
99- } ,
100- ] ,
101- } ,
102- ] ,
103- } ,
104- ] ,
105- } ) ;
106- } ,
107- family : ( version : string ) : string => {
108- return baseEmojiTest ( {
109- version,
110- separator : ";" ,
111- commentPrefix : "#" ,
112- input : [
113- {
114- group : "People & Body" ,
115- subgroups : [
116- {
117- subgroup : "family" ,
118- entries : [
119- {
120- codePoints : [ "1F468" , "200D" , "1F469" , "200D" , "1F467" ] ,
121- status : "fully-qualified" ,
122- comment : "family: man, woman, girl" ,
123- } ,
124- {
125- codePoints : [ "1F468" , "200D" , "1F469" , "200D" , "1F467" , "200D" , "1F466" ] ,
126- status : "fully-qualified" ,
127- comment : "family: man, woman, girl, boy" ,
128- } ,
129- {
130- codePoints : [ "1F468" , "200D" , "1F469" , "200D" , "1F466" , "200D" , "1F466" ] ,
131- status : "fully-qualified" ,
132- comment : "family: man, woman, boy, boy" ,
133- } ,
134- ] ,
135- } ,
136- ] ,
137- } ,
138- ] ,
139- } ) ;
140- } ,
141-
142- flag : ( version : string ) : string => {
143- return baseEmojiTest ( {
144- version,
145- separator : ";" ,
146- commentPrefix : "#" ,
147- input : [
148- {
149- group : "Flags" ,
150- subgroups : [
151- {
152- subgroup : "country-flag" ,
153- entries : [
154- {
155- codePoints : [ "1F1E6" , "1F1E8" ] ,
156- status : "fully-qualified" ,
157- comment : "flag: Argentina" ,
158- } ,
159- {
160- codePoints : [ "1F1E6" , "1F1F4" ] ,
161- status : "fully-qualified" ,
162- comment : "flag: Angola" ,
163- } ,
164- {
165- codePoints : [ "1F1E6" , "1F1F6" ] ,
166- status : "fully-qualified" ,
167- comment : "flag: Antarctica" ,
168- } ,
169- ] ,
170- } ,
171- ] ,
172- } ,
173- ] ,
174- } ) ;
61+ presets : {
62+ smileys : bundledSmileys ,
63+ flags : bundledFlags ,
17564 } ,
17665} ) ;
0 commit comments