Files
twenty/packages/twenty-front/src/utils/__tests__/utils.test.ts
Sohal Kumar Singh 368edf70b5 Fixed favicon requests for empty domain names (#4191)
* Fixed favicon requests for empty domain names

* Fixed the test case for undefined domain name
2024-02-27 08:31:51 +01:00

48 lines
1.5 KiB
TypeScript

import { getLogoUrlFromDomainName, sanitizeURL } from '..';
describe('sanitizeURL', () => {
test('should sanitize the URL correctly', () => {
expect(sanitizeURL('http://example.com/')).toBe('example.com');
expect(sanitizeURL('https://www.example.com/')).toBe('example.com');
expect(sanitizeURL('www.example.com')).toBe('example.com');
expect(sanitizeURL('example.com')).toBe('example.com');
expect(sanitizeURL('example.com/')).toBe('example.com');
});
test('should handle undefined input', () => {
expect(sanitizeURL(undefined)).toBe('');
});
});
describe('getLogoUrlFromDomainName', () => {
test('should return the correct logo URL for a given domain', () => {
expect(getLogoUrlFromDomainName('example.com')).toBe(
'https://favicon.twenty.com/example.com',
);
expect(getLogoUrlFromDomainName('http://example.com/')).toBe(
'https://favicon.twenty.com/example.com',
);
expect(getLogoUrlFromDomainName('https://www.example.com/')).toBe(
'https://favicon.twenty.com/example.com',
);
expect(getLogoUrlFromDomainName('www.example.com')).toBe(
'https://favicon.twenty.com/example.com',
);
expect(getLogoUrlFromDomainName('example.com/')).toBe(
'https://favicon.twenty.com/example.com',
);
expect(getLogoUrlFromDomainName('apple.com')).toBe(
'https://favicon.twenty.com/apple.com',
);
});
test('should handle undefined input', () => {
expect(getLogoUrlFromDomainName(undefined)).toBe(undefined);
});
});