@@ -81,7 +81,7 @@ describe('validateJson', () => {
8181 } ,
8282 } ) ,
8383 ) . toThrowError (
84- 'Tokens validation error: instance.tokens.border-radius-one.$value does not match pattern "\\\\d+(px|rem|%)"' ,
84+ 'Tokens validation error: instance.tokens.border-radius-one.$value does not match pattern "^ \\\\d+(\\\\.\\\\d+)?( px|rem|%)$ "' ,
8585 ) ;
8686 } ) ;
8787
@@ -158,7 +158,7 @@ describe('validateJson', () => {
158158 } ,
159159 } ) ,
160160 ) . toBe ( true ) ;
161- [ '100 px' , '20ps' , '100 %' ] . forEach ( ( invalidValue ) => {
161+ [ '100 px' , '20ps' , '100 %' , '100px a' ] . forEach ( ( invalidValue ) => {
162162 expect ( ( ) =>
163163 validateTokens ( {
164164 'space-button' : {
@@ -169,7 +169,7 @@ describe('validateJson', () => {
169169 } ,
170170 } ) ,
171171 ) . toThrowError (
172- 'Tokens validation error: instance.tokens.space-button.$value.comfortable does not match pattern "\\\\d+(px|rem|%)"' ,
172+ 'Tokens validation error: instance.tokens.space-button.$value.comfortable does not match pattern "^ \\\\d+(\\\\.\\\\d+)?( px|rem|%)$ "' ,
173173 ) ;
174174 } ) ;
175175 } ) ;
@@ -269,6 +269,62 @@ describe('validateJson', () => {
269269 } ) ;
270270 } ) ;
271271
272+ describe ( 'font-size' , ( ) => {
273+ test ( 'accepts certain formats' , ( ) => {
274+ [ '14px' , '2rem' , '1em' , '1.5rem' ] . forEach ( ( validValue ) => {
275+ expect (
276+ validateTokens ( {
277+ 'font-size-body' : {
278+ $value : validValue ,
279+ } ,
280+ } ) ,
281+ ) . toBe ( true ) ;
282+ } ) ;
283+ } ) ;
284+
285+ test ( 'rejects invalid formats' , ( ) => {
286+ [ '14' , '14 px' , '14ps' , '1em a' ] . forEach ( ( invalidValue ) => {
287+ expect ( ( ) =>
288+ validateTokens ( {
289+ 'font-size-body' : {
290+ $value : invalidValue ,
291+ } ,
292+ } ) ,
293+ ) . toThrowError (
294+ 'Tokens validation error: instance.tokens.font-size-body.$value does not match pattern "^\\\\d+(\\\\.\\\\d+)?(px|rem|em)$"' ,
295+ ) ;
296+ } ) ;
297+ } ) ;
298+ } ) ;
299+
300+ describe ( 'line-height' , ( ) => {
301+ test ( 'accepts certain formats' , ( ) => {
302+ [ '20px' , '1.5rem' , '1em' ] . forEach ( ( validValue ) => {
303+ expect (
304+ validateTokens ( {
305+ 'line-height-body' : {
306+ $value : validValue ,
307+ } ,
308+ } ) ,
309+ ) . toBe ( true ) ;
310+ } ) ;
311+ } ) ;
312+
313+ test ( 'rejects invalid formats' , ( ) => {
314+ [ '20' , '20 px' , '20ps' , '1em a' ] . forEach ( ( invalidValue ) => {
315+ expect ( ( ) =>
316+ validateTokens ( {
317+ 'line-height-body' : {
318+ $value : invalidValue ,
319+ } ,
320+ } ) ,
321+ ) . toThrowError (
322+ 'Tokens validation error: instance.tokens.line-height-body.$value does not match pattern "^\\\\d+(\\\\.\\\\d+)?(px|rem|em)$"' ,
323+ ) ;
324+ } ) ;
325+ } ) ;
326+ } ) ;
327+
272328 describe ( 'letter spacing' , ( ) => {
273329 test ( 'accepts positive, negative, and zero values with valid units' , ( ) => {
274330 [ '1px' , '-0.5rem' , '0em' , '0.25px' , '-1.5em' , '.5px' , '-.5rem' ] . forEach ( ( validValue ) => {
@@ -295,15 +351,15 @@ describe('validateJson', () => {
295351 } ) ;
296352
297353 test ( 'rejects invalid formats' , ( ) => {
298- [ '100' , '-1' , '1.5' , '100 px' , '20ps' , '.px' , '-.rem' ] . forEach ( ( invalidValue ) => {
354+ [ '100' , '-1' , '1.5' , '100 px' , '20ps' , '.px' , '-.rem' , 'revert-' , '1px test' ] . forEach ( ( invalidValue ) => {
299355 expect ( ( ) =>
300356 validateTokens ( {
301357 'letter-spacing-button' : {
302358 $value : invalidValue ,
303359 } ,
304360 } ) ,
305361 ) . toThrowError (
306- 'Tokens validation error: instance.tokens.letter-spacing-button.$value does not match pattern "normal|inherit|initial|revert|revert-layer|unset|-?\\\\d*\\\\.?\\\\d+(px|rem|em)"' ,
362+ 'Tokens validation error: instance.tokens.letter-spacing-button.$value does not match pattern "^( normal|inherit|initial|revert|revert-layer|unset|-?\\\\d*\\\\.?\\\\d+(px|rem|em))$ "' ,
307363 ) ;
308364 } ) ;
309365 } ) ;
0 commit comments