[TWRNC] Added typography test#752
Conversation
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive type and runtime tests for typography definitions in the @metamask/design-system-twrnc-preset package and updates Jest configuration to focus coverage on the typography implementation.
- Added
typography.types.test.tsto validate TypeScript unions and structure for typography types. - Added
typography.test.tsto verify the runtimetypographyTailwindConfigobject matches design token expectations. - Updated
jest.config.jsto collect coverage only fromsrc/typography.tsand ignore pure type files.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/design-system-twrnc-preset/src/typography.types.test.ts | New type-level tests covering TypographyVariant, FontWeight, FontStyle, and TypographyTailwindConfigProps. |
| packages/design-system-twrnc-preset/src/typography.test.ts | New runtime tests validating the actual config object for font sizes, families, letter spacing, and line heights. |
| packages/design-system-twrnc-preset/jest.config.js | Jest configuration tweaks: restrict coverage to typography.ts, exclude type files, and merge array options. |
Comments suppressed due to low confidence (2)
packages/design-system-twrnc-preset/src/typography.types.test.ts:79
- This test only checks the length of
testWeights; add assertions such astoStrictEqual([...])to verify the actual set of weight values is correct and in the expected order.
expect(testWeights).toHaveLength(11);
packages/design-system-twrnc-preset/src/typography.types.test.ts:228
- [nitpick] The variable
requiredFontFamilyKeyshere differs fromexpectedFontFamiliesin the runtime tests; consider harmonizing naming conventions across test suites for clarity.
const requiredFontFamilyKeys = [
| describe('typography types', () => { | ||
| describe('TypographyVariant', () => { | ||
| it('includes all expected typography variants', () => { | ||
| const expectedVariants = [ | ||
| 'display-lg', | ||
| 'display-md', | ||
| 'heading-lg', | ||
| 'heading-md', | ||
| 'heading-sm', | ||
| 'body-lg', | ||
| 'body-md', | ||
| 'body-sm', | ||
| 'body-xs', | ||
| ]; | ||
|
|
||
| const testVariants: TypographyVariant[] = | ||
| expectedVariants as TypographyVariant[]; | ||
| expect(testVariants).toHaveLength(9); | ||
| expect(testVariants).toStrictEqual(expectedVariants); | ||
| }); | ||
|
|
||
| it('can be used as union type', () => { | ||
| const testFunction = (variant: TypographyVariant): string => variant; | ||
|
|
||
| expect(testFunction('display-lg')).toBe('display-lg'); | ||
| expect(testFunction('display-md')).toBe('display-md'); | ||
| expect(testFunction('heading-lg')).toBe('heading-lg'); | ||
| expect(testFunction('heading-md')).toBe('heading-md'); | ||
| expect(testFunction('heading-sm')).toBe('heading-sm'); | ||
| expect(testFunction('body-lg')).toBe('body-lg'); | ||
| expect(testFunction('body-md')).toBe('body-md'); | ||
| expect(testFunction('body-sm')).toBe('body-sm'); | ||
| expect(testFunction('body-xs')).toBe('body-xs'); | ||
| }); | ||
|
|
||
| it('can be used as object keys', () => { | ||
| const testObject: Record<TypographyVariant, string> = { | ||
| 'display-lg': 'test', | ||
| 'display-md': 'test', | ||
| 'heading-lg': 'test', | ||
| 'heading-md': 'test', | ||
| 'heading-sm': 'test', | ||
| 'body-lg': 'test', | ||
| 'body-md': 'test', | ||
| 'body-sm': 'test', | ||
| 'body-xs': 'test', | ||
| }; |
There was a problem hiding this comment.
[nitpick] The expectedVariants array is duplicated across multiple test files; consider extracting it into a shared constant or fixture to reduce duplication and improve maintainability.
| describe('typography types', () => { | |
| describe('TypographyVariant', () => { | |
| it('includes all expected typography variants', () => { | |
| const expectedVariants = [ | |
| 'display-lg', | |
| 'display-md', | |
| 'heading-lg', | |
| 'heading-md', | |
| 'heading-sm', | |
| 'body-lg', | |
| 'body-md', | |
| 'body-sm', | |
| 'body-xs', | |
| ]; | |
| const testVariants: TypographyVariant[] = | |
| expectedVariants as TypographyVariant[]; | |
| expect(testVariants).toHaveLength(9); | |
| expect(testVariants).toStrictEqual(expectedVariants); | |
| }); | |
| it('can be used as union type', () => { | |
| const testFunction = (variant: TypographyVariant): string => variant; | |
| expect(testFunction('display-lg')).toBe('display-lg'); | |
| expect(testFunction('display-md')).toBe('display-md'); | |
| expect(testFunction('heading-lg')).toBe('heading-lg'); | |
| expect(testFunction('heading-md')).toBe('heading-md'); | |
| expect(testFunction('heading-sm')).toBe('heading-sm'); | |
| expect(testFunction('body-lg')).toBe('body-lg'); | |
| expect(testFunction('body-md')).toBe('body-md'); | |
| expect(testFunction('body-sm')).toBe('body-sm'); | |
| expect(testFunction('body-xs')).toBe('body-xs'); | |
| }); | |
| it('can be used as object keys', () => { | |
| const testObject: Record<TypographyVariant, string> = { | |
| 'display-lg': 'test', | |
| 'display-md': 'test', | |
| 'heading-lg': 'test', | |
| 'heading-md': 'test', | |
| 'heading-sm': 'test', | |
| 'body-lg': 'test', | |
| 'body-md': 'test', | |
| 'body-sm': 'test', | |
| 'body-xs': 'test', | |
| }; | |
| const EXPECTED_VARIANTS = [ | |
| 'display-lg', | |
| 'display-md', | |
| 'heading-lg', | |
| 'heading-md', | |
| 'heading-sm', | |
| 'body-lg', | |
| 'body-md', | |
| 'body-sm', | |
| 'body-xs', | |
| ]; | |
| describe('typography types', () => { | |
| describe('TypographyVariant', () => { | |
| it('includes all expected typography variants', () => { | |
| const testVariants: TypographyVariant[] = | |
| EXPECTED_VARIANTS as TypographyVariant[]; | |
| expect(testVariants).toHaveLength(9); | |
| expect(testVariants).toStrictEqual(EXPECTED_VARIANTS); | |
| }); | |
| it('can be used as union type', () => { | |
| const testFunction = (variant: TypographyVariant): string => variant; | |
| EXPECTED_VARIANTS.forEach((variant) => { | |
| expect(testFunction(variant)).toBe(variant); | |
| }); | |
| }); | |
| it('can be used as object keys', () => { | |
| const testObject: Record<TypographyVariant, string> = Object.fromEntries( | |
| EXPECTED_VARIANTS.map((variant) => [variant, 'test']) | |
| ) as Record<TypographyVariant, string>; |
📖 Storybook Preview |
|
@cursoragent update PR with latest and fix failing ci tests |
I also updated PR #752 to base |
…y-test Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…bel-jest transform Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…current API Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…ependency Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|
Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|


Description
This PR adds tests to the typography in the @metamask/design-system-twrnc-preset package
Related issues
Fixes:
Manual testing steps
yarn testfrom package/design-system-twrnc-presetScreenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist