diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2024-04-14 15:30:44 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2024-04-14 15:38:50 +0200 |
| commit | 23d77288040ca113dbc797aa2eaff6ba2a32f324 (patch) | |
| tree | c14a8417684dd54ea7425f7bc64d52d315973ad4 /tests/feed-rss.spec.js | |
| parent | 77b73fceb49bff397dab6badb7df8e821960fe2b (diff) | |
| download | gohugo-theme-ed-23d77288040ca113dbc797aa2eaff6ba2a32f324.tar.gz | |
Move site author configuration to params
Diffstat (limited to 'tests/feed-rss.spec.js')
| -rw-r--r-- | tests/feed-rss.spec.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/feed-rss.spec.js b/tests/feed-rss.spec.js new file mode 100644 index 0000000..2927140 --- /dev/null +++ b/tests/feed-rss.spec.js @@ -0,0 +1,58 @@ +'use strict'; + +// @ts-check +const { test, expect } = require('@playwright/test'); +const jsdom = require('jsdom'); +const { JSDOM } = jsdom; + +test('rss feed has correct lastBuildDate field', async ({ page }) => { + await page.goto('/feeds/feed.rss.xml'); + + // Get the content of the page + const content = await page.content(); + + // Create a new JSDOM instance + const dom = new JSDOM(content, { contentType: 'text/xml' }); + + // Get the global window object + const { window } = dom; + + // Get the lastBuildDate field + const lastBuildDateField = window.document.querySelector('rss > lastBuildDate'); + + // Check if the lastBuildDate field exists + expect(lastBuildDateField).not.toBeNull(); + + // Check if the lastBuildDate field is not empty + expect(lastBuildDateField.textContent.trim()).not.toBe(''); + + // Check if the lastBuildDate field has the correct format + const dateRegex = /^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} [+-]\d{4}$/; + expect(lastBuildDateField.textContent).toMatch(dateRegex); +}); + +test('rss feed has correct author information', async ({ page }) => { + await page.goto('/feeds/feed.rss.xml'); + + // Get the content of the page + const content = await page.content(); + + // Create a new JSDOM instance + const dom = new JSDOM(content, { contentType: 'text/xml' }); + + // Get the global window object + const { window } = dom; + + // Get the dc:creator element + const creatorElement = window.document.querySelector('rss > dc\\:creator'); + + // Check if the dc:creator element exists + expect(creatorElement).not.toBeNull(); + + // Check if the dc:creator element has the correct type attribute + expect(creatorElement.getAttribute('type')).toBe('html'); + + // Check if the dc:creator element has the correct text content + expect(creatorElement.textContent).not.toBeNull(); + expect(creatorElement.textContent.trim()).not.toBe(''); +}); |
