77 */
88import { readFileSync } from 'node:fs'
99import { join } from 'node:path'
10+ import { chipGeometryClass } from '@sim/emcn/components/chip/chip-chrome'
1011import { describe , expect , it } from 'vitest'
1112import { baseStyles , colors , typography } from '@/components/emails/_styles'
1213
1314const APP_ROOT = join ( __dirname , '../../..' )
1415
1516const globalsCss = readFileSync ( join ( APP_ROOT , 'app/_styles/globals.css' ) , 'utf8' )
16- const chipChrome = readFileSync (
17- join ( APP_ROOT , '../../packages/emcn/src/components/chip/chip-chrome.ts' ) ,
18- 'utf8'
19- )
2017
2118/**
2219 * The type scale moved into the `@theme` block when the v4 upgrade removed
@@ -85,7 +82,7 @@ describe('email type scale mirrors the globals.css @theme scale', () => {
8582 it ( 'sm is Tailwind stock 14px — the size text-sm resolves to in chip chrome' , ( ) => {
8683 expect ( typography . fontSize . sm ) . toBe ( '14px' )
8784 expect ( tailwindFontSize . sm ) . toBeUndefined ( )
88- expect ( chipChrome ) . toContain ( 'text-sm' )
85+ expect ( chipGeometryClass ) . toContain ( 'text-sm' )
8986 } )
9087
9188 it ( 'display is deliberately off-scale — the platform has no headline numeral' , ( ) => {
@@ -101,18 +98,9 @@ describe('email geometry mirrors the platform', () => {
10198 } )
10299
103100 it ( 'the CTA transcribes chipGeometryClass' , ( ) => {
104- // chipGeometryClass composes the unrounded geometry with the default radius,
105- // so the transcription reads both halves rather than one literal.
106- expect ( chipChrome ) . toMatch (
107- / c h i p G e o m e t r y C l a s s = ` \$ \{ c h i p G e o m e t r y U n r o u n d e d C l a s s \} \$ \{ c h i p R a d i u s C l a s s \} ` /
108- )
109- const unrounded = chipChrome . match ( / c h i p G e o m e t r y U n r o u n d e d C l a s s = ` ( [ ^ ` ] + ) ` / ) ?. [ 1 ]
110- const radius = chipChrome . match ( / c h i p R a d i u s C l a s s = ' ( [ ^ ' ] + ) ' / ) ?. [ 1 ]
111- expect ( unrounded ) . toBeDefined ( )
112- expect ( radius ) . toBeDefined ( )
113- const geometry = `${ unrounded } ${ radius } `
101+ // Read the composed token so splitting shared constants cannot hide drift.
114102 for ( const token of [ 'h-[30px]' , 'rounded-lg' , 'px-2' , 'text-sm' ] ) {
115- expect ( geometry ) . toContain ( token )
103+ expect ( chipGeometryClass ) . toContain ( token )
116104 }
117105
118106 expect ( baseStyles . button . lineHeight ) . toBe ( '30px' )
0 commit comments