Skip to content

[TWRNC] Added typography test#752

Draft
brianacnguyen wants to merge 15 commits into
mainfrom
chore/twrnc-typography-test
Draft

[TWRNC] Added typography test#752
brianacnguyen wants to merge 15 commits into
mainfrom
chore/twrnc-typography-test

Conversation

@brianacnguyen

Copy link
Copy Markdown
Contributor

Description

This PR adds tests to the typography in the @metamask/design-system-twrnc-preset package

Related issues

Fixes:

Manual testing steps

  1. Run yarn test from package/design-system-twrnc-preset

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@brianacnguyen brianacnguyen requested a review from a team as a code owner June 12, 2025 00:42
@brianacnguyen brianacnguyen self-assigned this Jun 12, 2025
@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 👎

@georgewrmarshall georgewrmarshall marked this pull request as draft June 30, 2025 15:27
@georgewrmarshall georgewrmarshall requested a review from Copilot July 16, 2025 21:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 runtime typographyTailwindConfig object matches design token expectations.
  • Updated jest.config.js to collect coverage only from src/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 as toStrictEqual([...]) 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 from expectedFontFamilies in the runtime tests; consider harmonizing naming conventions across test suites for clarity.
      const requiredFontFamilyKeys = [

Comment on lines +8 to +54
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',
};

Copilot AI Jul 16, 2025

Copy link

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.

Suggested change
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.
@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall

Copy link
Copy Markdown
Contributor

@cursoragent update PR with latest and fix failing ci tests

@cursor

cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor
  • Merged latest main into branch chore/twrnc-typography-test and pushed.
  • Fixed the failing package tests by dropping the react-native Jest preset in @metamask/design-system-twrnc-preset, adding an explicit babel-jest transform, and updating tests to align with current tokens (Geist font family) and API (no fontWeight in style tuple).
  • Enabled Flow parsing for tests (added @babel/preset-flow and updated babel.config.js). Verified yarn test passes for packages/design-system-twrnc-preset.

I also updated PR #752 to base main.

Open in Web Open in Cursor 

…y-test

Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
cursoragent and others added 4 commits July 6, 2026 17:00
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>
@socket-security

socket-security Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​babel/​preset-flow@​8.0.11001007195100

View full report

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 Pull Request Preview

🌳 Main Branch (Latest)

Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 Pull Request Preview

🌳 Main Branch (Latest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants