Skip to content

Commit

Permalink
Add tests for radius tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
georgewrmarshall committed Oct 11, 2024
1 parent faf9365 commit 136a7f2
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/js/radius/radius.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { RadiusToken } from './radius';
import { radius } from './radius';

describe('radius', () => {
it('should have the correct number of tokens', () => {
expect(Object.keys(radius)).toHaveLength(8);
});

it('should have the correct token names', () => {
const expectedTokens: RadiusToken[] = [
'none',
'sm',
'md',
'lg',
'xl',
'2xl',
'3xl',
'full',
];
expect(Object.keys(radius)).toEqual(expectedTokens);

Check failure on line 20 in src/js/radius/radius.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

Use `toStrictEqual()` instead
});

it('should have the correct values for each token', () => {
expect(radius.none).toBe('0');
expect(radius.sm).toBe('0.125rem');
expect(radius.md).toBe('0.25rem');
expect(radius.lg).toBe('0.5rem');
expect(radius.xl).toBe('1rem');
expect(radius['2xl']).toBe('1.5rem');
expect(radius['3xl']).toBe('2rem');
expect(radius.full).toBe('9999px');
});

it('should not allow adding new properties', () => {
// @ts-expect-error

Check failure on line 35 in src/js/radius/radius.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer
expect(() => (radius.newProperty = '1px')).toThrow();

Check failure on line 36 in src/js/radius/radius.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint

Add an error message to toThrow()
});
});

0 comments on commit 136a7f2

Please sign in to comment.