Skip to content

Commit 31c22d0

Browse files
committed
test: add CodePen profile page exclusion regression tests
1 parent e93e4a6 commit 31c22d0

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

test/unit/server/utils/readme.spec.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,42 @@ describe('Playground Link Extraction', () => {
8484
})
8585

8686
describe('Other Providers', () => {
87-
it('extracts CodePen links', async () => {
87+
it('extracts CodePen pen links', async () => {
8888
const markdown = `[Pen](https://codepen.io/user/pen/abc123)`
8989
const result = await renderReadmeHtml(markdown, 'test-pkg')
9090

9191
expect(result.playgroundLinks[0]!.provider).toBe('codepen')
9292
})
9393

94+
it('does not treat a CodePen profile page as a playground link', async () => {
95+
// https://codepen.io/username is a profile page, not a pen
96+
const markdown = `[Profile](https://codepen.io/username)`
97+
const result = await renderReadmeHtml(markdown, 'test-pkg')
98+
99+
expect(result.playgroundLinks).toHaveLength(0)
100+
})
101+
102+
it('does not treat a CodePen collection page as a playground link', async () => {
103+
const markdown = `[Collection](https://codepen.io/username/pens/public)`
104+
const result = await renderReadmeHtml(markdown, 'test-pkg')
105+
106+
expect(result.playgroundLinks).toHaveLength(0)
107+
})
108+
109+
it('extracts CodePen full-page links', async () => {
110+
const markdown = `[Full](https://codepen.io/user/full/abc123)`
111+
const result = await renderReadmeHtml(markdown, 'test-pkg')
112+
113+
expect(result.playgroundLinks[0]!.provider).toBe('codepen')
114+
})
115+
116+
it('extracts CodePen details links', async () => {
117+
const markdown = `[Details](https://codepen.io/user/details/abc123)`
118+
const result = await renderReadmeHtml(markdown, 'test-pkg')
119+
120+
expect(result.playgroundLinks[0]!.provider).toBe('codepen')
121+
})
122+
94123
it('extracts Replit links', async () => {
95124
const markdown = `[Repl](https://replit.com/@user/project)`
96125
const result = await renderReadmeHtml(markdown, 'test-pkg')

0 commit comments

Comments
 (0)