-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.test.ts
35 lines (29 loc) · 1.34 KB
/
utils.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { formatLinkList } from './utils';
describe('formatLinkList', () => {
it('should format a single markdown link into a list item', () => {
const input = '[Example](https://example.com)';
const expected = '- [Example](https://example.com)';
expect(formatLinkList(input)).toBe(expected);
});
it('should handle multiple links', () => {
const input = '[Example1](https://example1.com) [Example2](https://example2.com)';
const expected = '- [Example1](https://example1.com)\n- [Example2](https://example2.com)';
expect(formatLinkList(input)).toBe(expected);
});
it('should remove duplicate URLs keeping the first occurrence', () => {
const input = '[First](https://example.com) [Second](https://example.com)';
const expected = '- [First](https://example.com)';
expect(formatLinkList(input)).toBe(expected);
});
it('should handle links with no title', () => {
const input = '[](https://example.com)';
const expected = '- [https://example.com](https://example.com)';
expect(formatLinkList(input)).toBe(expected);
});
it('should handle empty input', () => {
expect(formatLinkList('')).toBe('');
});
it('should handle input with no links', () => {
expect(formatLinkList('just some text')).toBe('');
});
});