mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-01-31 00:53:37 +00:00
41 lines
994 B
TypeScript
41 lines
994 B
TypeScript
|
import { cn, absoluteUrl } from '@/lib/utils';
|
||
|
|
||
|
describe('absoluteUrl', () => {
|
||
|
const originalEnv = process.env;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
process.env = {
|
||
|
...originalEnv,
|
||
|
NEXT_PUBLIC_APP_URL: 'https://example.com',
|
||
|
};
|
||
|
});
|
||
|
|
||
|
afterEach(() => {
|
||
|
process.env = originalEnv;
|
||
|
});
|
||
|
|
||
|
it('should return the correct absolute URL', () => {
|
||
|
const pathname = '/test';
|
||
|
expect(absoluteUrl(pathname)).toBe('https://example.com/test');
|
||
|
});
|
||
|
|
||
|
it('should handle empty pathname', () => {
|
||
|
const pathname = '';
|
||
|
expect(absoluteUrl(pathname)).toBe('https://example.com');
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('cn', () => {
|
||
|
it('should merge multiple class names', () => {
|
||
|
expect(cn('class1', 'class2')).toBe('class1 class2');
|
||
|
});
|
||
|
|
||
|
it('should handle conditional class names', () => {
|
||
|
const isActive = true;
|
||
|
expect(cn('base', isActive && 'active')).toBe('base active');
|
||
|
|
||
|
const isDisabled = false;
|
||
|
expect(cn('base', isDisabled && 'disabled')).toBe('base');
|
||
|
});
|
||
|
});
|