Skip to content

Commit

Permalink
tests(shared): added mergeClasses tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jguddas committed Sep 28, 2024
1 parent c6a4908 commit 25e342e
Show file tree
Hide file tree
Showing 3 changed files with 272 additions and 10 deletions.
9 changes: 8 additions & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@
"types": "src/index.ts",
"type": "module",
"author": "",
"license": "ISC"
"license": "ISC",
"scripts": {
"test": "vitest run",
"test:watch": "vitest watch"
},
"devDependencies": {
"vitest": "^2.1.1"
}
}
21 changes: 21 additions & 0 deletions packages/shared/tests/utils.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { describe, it, expect } from 'vitest';
import { mergeClasses } from '../src/utils';

describe('mergeClasses', () => {
it('merges classes', async () => {
const classes = mergeClasses('lucide', 'lucide-circle', 'custom-class');
expect(classes).toBe('lucide lucide-circle custom-class');
});
it('ignores empty string', async () => {
const classes = mergeClasses('lucide', 'lucide-circle', '');
expect(classes).toBe('lucide lucide-circle');
});
it('ignores undefined', async () => {
const classes = mergeClasses('lucide', 'lucide-circle', undefined);
expect(classes).toBe('lucide lucide-circle');
});
it('removes duplicates', async () => {
const classes = mergeClasses('lucide', 'lucide-circle', 'lucide');
expect(classes).toBe('lucide lucide-circle');
});
});
Loading

0 comments on commit 25e342e

Please sign in to comment.