UNPKG

@spoolcms/nextjs

Version:

The beautiful headless CMS for Next.js developers

41 lines (40 loc) 1.32 kB
"use strict"; /** * Test for markdown field functionality */ Object.defineProperty(exports, "__esModule", { value: true }); const content_1 = require("../utils/content"); // Mock fetch global.fetch = jest.fn(); describe('Markdown Fields', () => { beforeEach(() => { jest.clearAllMocks(); }); it('should handle markdown fields correctly', async () => { const config = { siteId: 'test-site', apiKey: 'test-key', baseUrl: 'http://localhost:3000' }; const mockItem = { id: '123', slug: 'test-post', data: { title: 'Test Post', body: '# Hello World', body_html: '<h1>Hello World</h1>' } }; global.fetch.mockResolvedValue({ ok: true, json: jest.fn().mockResolvedValue(mockItem), clone: jest.fn().mockReturnThis() }); const post = await (0, content_1.getSpoolContent)({ collection: 'blog', slug: 'test-post', config: config }); // Should return HTML by default expect(typeof post.body).toBe('string'); expect(post.body).toBe('<h1>Hello World</h1>'); // Should have markdown field expect(post.body_markdown).toBe('# Hello World'); }); });