|
| 1 | +import assert from 'node:assert/strict'; |
| 2 | +import { after, before, describe, it } from 'node:test'; |
| 3 | +import { isWindows, loadFixture } from './test-utils.js'; |
| 4 | + |
| 5 | +const UPDATED_CONTENT = '---\ntitle: HMR Markdown\n---\n\nUpdated content\n'; |
| 6 | + |
| 7 | +describe('HMR: Markdown updates', () => { |
| 8 | + /** @type {import('./test-utils').Fixture} */ |
| 9 | + let fixture; |
| 10 | + /** @type {import('./test-utils').DevServer} */ |
| 11 | + let devServer; |
| 12 | + /** @type {string} */ |
| 13 | + let markdownPath; |
| 14 | + |
| 15 | + before(async () => { |
| 16 | + fixture = await loadFixture({ root: './fixtures/hmr-markdown/' }); |
| 17 | + devServer = await fixture.startDevServer(); |
| 18 | + |
| 19 | + markdownPath = '/src/content/blog/post.md'; |
| 20 | + }); |
| 21 | + |
| 22 | + after(async () => { |
| 23 | + await devServer.stop(); |
| 24 | + }); |
| 25 | + |
| 26 | + it( |
| 27 | + 'should update HTML when markdown changes', |
| 28 | + { skip: isWindows, todo: 'HMR tests hang on Windows' }, |
| 29 | + async () => { |
| 30 | + let response = await fixture.fetch('/'); |
| 31 | + assert.equal(response.status, 200); |
| 32 | + let html = await response.text(); |
| 33 | + assert.ok(html.includes('Original content')); |
| 34 | + |
| 35 | + await fixture.editFile(markdownPath, UPDATED_CONTENT); |
| 36 | + await fixture.onNextDataStoreChange(); |
| 37 | + |
| 38 | + response = await fixture.fetch('/'); |
| 39 | + assert.equal(response.status, 200); |
| 40 | + html = await response.text(); |
| 41 | + assert.ok(html.includes('Updated content')); |
| 42 | + }, |
| 43 | + ); |
| 44 | +}); |
0 commit comments