dockerfile/examples/omnivore/content-fetch/content-handler/test/github-handler.test.ts

33 lines
869 B
TypeScript
Raw Normal View History

2024-03-15 14:52:38 +08:00
import { GitHubHandler } from '../src/websites/github-handler'
import 'mocha'
import { expect } from 'chai'
import { parseHTML } from 'linkedom'
describe('preParse', () => {
it('should update the title on the page', async () => {
const dom = parseHTML(
`
<html>
<head>
<meta name="twitter:title"
content="GitHub - owner/repo: This is a title with a / char"
/>
</head>
<body>
<article>this is the content of the article</article>
</body>
</html>
`
)
const result = await new GitHubHandler().preParse(
'https://github.com/siyuan-note/siyuan',
dom.document
)
const title = result
.querySelector(`meta[name='twitter:title']`)
?.getAttribute('content')
expect(title).to.eq(`repo: This is a title with a / char`)
})
})