-
-
Notifications
You must be signed in to change notification settings - Fork 5
[TWRNC] Added typography test #752
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
base: main
Are you sure you want to change the base?
Conversation
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
📖 Storybook Preview |
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.
✅ BugBot reviewed your changes and found no bugs!
Was this report helpful? Give feedback by reacting with 👍 or 👎
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.
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.ts
to validate TypeScript unions and structure for typography types. - Added
typography.test.ts
to verify the runtimetypographyTailwindConfig
object matches design token expectations. - Updated
jest.config.js
to collect coverage only fromsrc/typography.ts
and 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
requiredFontFamilyKeys
here differs fromexpectedFontFamilies
in 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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>; |
Copilot uses AI. Check for mistakes.
📖 Storybook Preview |
Description
This PR adds tests to the typography in the @metamask/design-system-twrnc-preset package
Related issues
Fixes:
Manual testing steps
yarn test
from package/design-system-twrnc-presetScreenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist