Skip to content

Commit

Permalink
test: add utils tests (#197)
Browse files Browse the repository at this point in the history
Co-authored-by: Danilo Alves <138066684+danilo-moreira-brisa@users.noreply.github.com>
  • Loading branch information
allan-chagas-brisa and danilo-moreira-brisa committed May 22, 2024
1 parent d7c0a1c commit cae603e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/components/utils/index.ts

This file was deleted.

8 changes: 8 additions & 0 deletions src/components/utils/spacing.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { spacing } from './spacing';

describe('spacing', () => {
it('should return the value with pixels in a scale of 8', () => {
const value = 2;
expect(spacing(value)).toBe('16px');
});
});
18 changes: 18 additions & 0 deletions src/components/utils/validateHexColor.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { validateHexColor } from './validateHexColor';

const validHexColors = ['#000000', '#000'];
const invalidHexColors = ['#AABBCC000', '#XXBBCC'];
describe('validateHexColor', () => {
it.each(invalidHexColors)(
'should return false if an invalid hexadecimal color is provided',
(value) => {
expect(validateHexColor(value)).toBe(false);
}
);
it.each(validHexColors)(
'should return false if a valid hexadecimal color is provided',
(value) => {
expect(validateHexColor(value)).toBe(true);
}
);
});

0 comments on commit cae603e

Please sign in to comment.