1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-28 16:48:00 +02:00
blog/src/lib/feed/feed.test.ts
2023-10-03 21:14:05 +01:00

35 lines
1.2 KiB
TypeScript

import { it, describe, expect } from 'vitest'
import { getFeedContent } from '.'
describe('getFeedContent', () => {
it('should generate post feed content with an image', async () => {
const mockPost = {
body: 'Mock post content in markdown format',
data: { image: { src: 'https://example.com/image.jpg' } }
}
const feedContent = await getFeedContent(mockPost as any)
expect(feedContent).toContain('<img src="https://example.com/image.jpg" />')
expect(feedContent).toContain('Mock post content in markdown format')
expect(feedContent).toContain(
'This post was published on <a href="https://kremalicious.com">kremalicious.com</a>'
)
})
it('should generate post feed content without an image', async () => {
const mockPost = {
body: 'Mock post content in markdown format',
data: {}
}
const feedContent = await getFeedContent(mockPost as any)
expect(feedContent).not.toContain('<img src="')
expect(feedContent).toContain('Mock post content in markdown format')
expect(feedContent).toContain(
'This post was published on <a href="https://kremalicious.com">kremalicious.com</a>'
)
})
})