Skip to content

Conversation

brianacnguyen
Copy link
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
Copy link
Contributor

📖 Storybook Preview

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

📖 Storybook Preview

Copy link
Contributor

📖 Storybook Preview

Copy link
Contributor

📖 Storybook Preview

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

📖 Storybook Preview

Copy link
Contributor

📖 Storybook Preview

Copy link

@cursor cursor bot left a 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 👎

@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
Copy link
Contributor

@Copilot Copilot AI left a 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 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',
};
Copy link
Preview

Copilot AI Jul 16, 2025

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.

Copy link
Contributor

📖 Storybook Preview

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.

2 participants