Skip to content

Commit ca5e9ff

Browse files
committed
test: drop the tests for the deleted json-ld helpers
1 parent ff2c87b commit ca5e9ff

1 file changed

Lines changed: 0 additions & 53 deletions

File tree

test/og.test.ts

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, expect, it } from 'vitest'
22
import { truncate, withAlpha } from '../app/utils/og'
3-
import { breadcrumbListLd, jsonLd } from '../app/utils/json-ld'
43

54
describe('withAlpha', () => {
65
it('expands 6-digit hex', () => {
@@ -40,55 +39,3 @@ describe('truncate', () => {
4039
expect(truncate('a'.repeat(20), 10)).toBe(`${'a'.repeat(10)}…`)
4140
})
4241
})
43-
44-
describe('jsonLd', () => {
45-
it('produces parseable JSON with the same values', () => {
46-
expect(JSON.parse(jsonLd({ a: 1, b: 'x' }))).toEqual({ a: 1, b: 'x' })
47-
})
48-
49-
it('escapes markup so a title cannot close the script element', () => {
50-
const output = jsonLd({ headline: 'Bad </script><img src=x>' })
51-
expect(output).not.toContain('</script>')
52-
expect(output).not.toContain('<')
53-
// Still decodes back to the original text.
54-
expect(JSON.parse(output).headline).toBe('Bad </script><img src=x>')
55-
})
56-
57-
it('escapes ampersands (HTML entity contexts)', () => {
58-
const output = jsonLd({ name: 'A & B' })
59-
expect(output).not.toContain('&')
60-
expect(JSON.parse(output).name).toBe('A & B')
61-
})
62-
})
63-
64-
describe('breadcrumbListLd', () => {
65-
it('emits position + item on every ListItem (Google requires item)', () => {
66-
expect(
67-
breadcrumbListLd([
68-
{ name: 'Docs', item: 'https://comark.dev' },
69-
{ name: 'Introduction', item: 'https://comark.dev/getting-started/introduction' },
70-
])
71-
).toEqual({
72-
'@context': 'https://schema.org',
73-
'@type': 'BreadcrumbList',
74-
itemListElement: [
75-
{ '@type': 'ListItem', position: 1, name: 'Docs', item: 'https://comark.dev' },
76-
{
77-
'@type': 'ListItem',
78-
position: 2,
79-
name: 'Introduction',
80-
item: 'https://comark.dev/getting-started/introduction',
81-
},
82-
],
83-
})
84-
})
85-
86-
it('never omits item, even for a single root crumb', () => {
87-
const list = breadcrumbListLd([{ name: 'Docs', item: 'https://comark.dev/' }])
88-
for (const entry of list.itemListElement) {
89-
expect(entry).toHaveProperty('item')
90-
expect(typeof entry.item).toBe('string')
91-
expect(entry.item.length).toBeGreaterThan(0)
92-
}
93-
})
94-
})

0 commit comments

Comments
 (0)