diff --git a/package.json b/package.json index 5a4e74e..d4c8e8f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "vite build", "release": "bash scripts/bump_version.sh", "release_verify": "bash scripts/prerelease_check.sh", - "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathIgnorePatterns=\\.e2e\\.test\\.js$", + "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules node_modules/jest/bin/jest.js --testPathIgnorePatterns=\\.e2e\\.test\\.js$", "e2e": "playwright test" }, "keywords": [ @@ -43,4 +43,4 @@ "tailwindcss": "^3.4.10", "vite": "^2.9.18" } -} +} \ No newline at end of file diff --git a/src/content/config.e2e.js b/src/content/e2e/config.e2e.js similarity index 72% rename from src/content/config.e2e.js rename to src/content/e2e/config.e2e.js index 457162d..26288d5 100644 --- a/src/content/config.e2e.js +++ b/src/content/e2e/config.e2e.js @@ -1,5 +1,6 @@ import { test as base, expect } from '@playwright/test' -import siteConfigs from './config.js' +import { e2eTestUrls } from './targets.js' +import siteConfigs from '../config.js' // Define a common user agent const COMMON_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' @@ -51,24 +52,7 @@ for (const [siteName, siteConfig] of Object.entries(siteConfigs)) { for (const [pageName, pageConfig] of Object.entries(siteConfig.pages)) { test(`${siteName} - ${pageName}`, async ({ page }) => { - const testUrls = { - github: { - pr: 'https://github.com/microsoft/playwright/pull/20635', - issue: 'https://github.com/microsoft/playwright/issues/20636', - discussion: 'https://github.com/golang/go/discussions/61669', - repo: 'https://github.com/microsoft/playwright', - user: 'https://github.com/microsoft', - release: 'https://github.com/microsoft/playwright/releases/tag/v1.32.3', - commit: 'https://github.com/golang/go/commit/96d8ff00c2d6a88384863a656fb5e53716b614d3', - actions: 'https://github.com/jonfriesen/quickcite/actions/runs/10446232111', - }, - instagram: { - profile: 'https://www.instagram.com/jonfriesen/', - }, - trello: { - board: 'https://trello.com/b/AwYSWOyt/ultimate-to-do-list', - }, - } + const testUrls = e2eTestUrls const testUrl = testUrls[siteName][pageName] await testPageConfig(page, testUrl, pageConfig) diff --git a/src/content/e2e/targets.js b/src/content/e2e/targets.js new file mode 100644 index 0000000..6a3be3a --- /dev/null +++ b/src/content/e2e/targets.js @@ -0,0 +1,18 @@ +export const e2eTestUrls = { + github: { + pr: 'https://github.com/microsoft/playwright/pull/20635', + issue: 'https://github.com/microsoft/playwright/issues/20636', + discussion: 'https://github.com/golang/go/discussions/61669', + repo: 'https://github.com/microsoft/playwright', + user: 'https://github.com/microsoft', + release: 'https://github.com/microsoft/playwright/releases/tag/v1.32.3', + commit: 'https://github.com/golang/go/commit/96d8ff00c2d6a88384863a656fb5e53716b614d3', + actions: 'https://github.com/jonfriesen/quickcite/actions/runs/10446232111', + }, + instagram: { + profile: 'https://www.instagram.com/jonfriesen/', + }, + trello: { + board: 'https://trello.com/b/AwYSWOyt/ultimate-to-do-list', + }, +} diff --git a/src/content/github.test.js b/src/content/github.test.js deleted file mode 100644 index ec48fdb..0000000 --- a/src/content/github.test.js +++ /dev/null @@ -1,110 +0,0 @@ -import siteConfigs from './config' - -describe('GitHub URL pattern tests', () => { - const testCases = [ - { page: 'pr', url: 'https://github.com/user/repo/pull/123', shouldMatch: true }, - { page: 'issue', url: 'https://github.com/user/repo/issues/456', shouldMatch: true }, - { page: 'discussion', url: 'https://github.com/user/repo/discussions/789', shouldMatch: true }, - { page: 'repo', url: 'https://github.com/user/repo', shouldMatch: true }, - { page: 'user', url: 'https://github.com/username', shouldMatch: true }, - { page: 'release', url: 'https://github.com/user/repo/releases/tag/v1.0.0', shouldMatch: true }, - { page: 'commit', url: 'https://github.com/user/repo/commit/1234567890123456789012345678901234567890', shouldMatch: true }, - { page: 'pr', url: 'https://github.com/user/repo', shouldMatch: false }, - { page: 'actions', url: 'https://github.com/jonfriesen/quickcite/actions/runs/10476888027', shouldMatch: true }, - { page: 'actions', url: 'https://github.com/octocat/Hello-World/actions/runs/12345678', shouldMatch: true }, - { page: 'actions', url: 'https://github.com/octocat/Hello-World/actions', shouldMatch: false }, - { page: 'actions', url: 'https://github.com/octocat/Hello-World/actions/runs/abcdefgh', shouldMatch: false }, - { page: 'actions', url: 'https://github.com/octocat/Hello-World/actions/runs/abcdefgh/job/12345678', shouldMatch: false }, - ] - - test.each(testCases)('$page: $url should ${shouldMatch ? "match" : "not match"}', ({ page, url, shouldMatch }) => { - const pattern = siteConfigs.github.pages[page].urlPattern - if (shouldMatch) { - expect(url).toMatch(pattern) - } else { - expect(url).not.toMatch(pattern) - } - }) -}) - -describe('GitHub markdown generator tests', () => { - const mockGetStatusEmoji = (status) => { - const statusMap = { - Queued: '⏳', - 'In progress': '🔄', - Success: '✅', - Failure: '❌', - Cancelled: '🚫', - Skipped: '⏭️', - } - return statusMap[status] || '' - } - - const markdownTestCases = [ - { - page: 'pr', - info: { number: '#123', title: 'Add new feature' }, - url: 'https://github.com/user/repo/pull/123', - expected: '[#123: Add new feature](https://github.com/user/repo/pull/123)', - }, - { - page: 'issue', - info: { number: '#456', title: 'Fix bug in login' }, - url: 'https://github.com/user/repo/issues/456', - expected: '[#456: Fix bug in login](https://github.com/user/repo/issues/456)', - }, - { - page: 'discussion', - info: { number: '#789', title: 'Propose new architecture' }, - url: 'https://github.com/user/repo/discussions/789', - expected: '[#789: Propose new architecture](https://github.com/user/repo/discussions/789)', - }, - { - page: 'repo', - info: { title: 'user/repo', description: 'A cool project' }, - url: 'https://github.com/user/repo', - expected: '[user/repo](https://github.com/user/repo) - A cool project', - }, - { - page: 'user', - info: { name: 'John Doe', bio: 'Software Developer' }, - url: 'https://github.com/johndoe', - expected: '[John Doe](https://github.com/johndoe) - Software Developer', - }, - { - page: 'release', - info: { title: 'v1.0.0: First Release', date: '2023-05-01T00:00:00Z' }, - url: 'https://github.com/user/repo/releases/tag/v1.0.0', - expected: '[v1.0.0: First Release](https://github.com/user/repo/releases/tag/v1.0.0) - Released on ' + new Date('2023-05-01T00:00:00Z').toLocaleDateString(), - }, - { - page: 'commit', - info: { title: 'Update README.md', hash: '1234567890abcdef', author: 'John Doe', date: '2023-05-01T00:00:00Z' }, - url: 'https://github.com/user/repo/commit/1234567890abcdef', - expected: '[(1234567) - Update README.md](https://github.com/user/repo/commit/1234567890abcdef)\nBy John Doe on ' + new Date('2023-05-01T00:00:00Z').toLocaleString(), - }, - { - page: 'actions', - info: { repoOwner: 'jonfriesen', repoName: 'quickcite', workflowName: 'CI', runNumber: '#1234', runStatus: 'Success', statusEmoji: '✅' }, - url: 'https://github.com/jonfriesen/quickcite/actions/runs/10476888027', - expected: '[jonfriesen/quickcite: CI #1234 ✅ (Success)](https://github.com/jonfriesen/quickcite/actions/runs/10476888027)', - }, - { - page: 'actions', - info: { repoOwner: 'octocat', repoName: 'Hello-World', workflowName: 'Build', runNumber: '#5678', runStatus: 'Failure', statusEmoji: '❌' }, - url: 'https://github.com/octocat/Hello-World/actions/runs/12345678', - expected: '[octocat/Hello-World: Build #5678 ❌ (Failure)](https://github.com/octocat/Hello-World/actions/runs/12345678)', - }, - { - page: 'actions', - info: { repoOwner: 'test', repoName: 'repo', workflowName: 'Deploy', runNumber: '#9012', runStatus: 'In progress', statusEmoji: '🔄' }, - url: 'https://github.com/test/repo/actions/runs/90123456', - expected: '[test/repo: Deploy #9012 🔄 (In progress)](https://github.com/test/repo/actions/runs/90123456)', - }, - ] - - test.each(markdownTestCases)('$page: should generate correct markdown', ({ page, info, url, expected }) => { - const buildMarkdown = siteConfigs.github.pages[page].buildMarkdown - expect(buildMarkdown(info, url)).toBe(expected) - }) -}) diff --git a/src/content/instagram.test.js b/src/content/instagram.test.js deleted file mode 100644 index 29ee75b..0000000 --- a/src/content/instagram.test.js +++ /dev/null @@ -1,33 +0,0 @@ -import siteConfigs from './config' - -describe('Instagram URL pattern tests', () => { - const testCases = [ - { page: 'profile', url: 'https://www.instagram.com/username/', shouldMatch: true }, - { page: 'profile', url: 'https://www.instagram.com/p/123456/', shouldMatch: false }, - ] - - test.each(testCases)('$page: $url should ${shouldMatch ? "match" : "not match"}', ({ page, url, shouldMatch }) => { - const pattern = siteConfigs.instagram.pages[page].urlPattern - if (shouldMatch) { - expect(url).toMatch(pattern) - } else { - expect(url).not.toMatch(pattern) - } - }) -}) - -describe('Instagram markdown generator tests', () => { - const markdownTestCases = [ - { - page: 'profile', - info: { name: 'Travel Enthusiast' }, - url: 'https://www.instagram.com/travelenthusiast/', - expected: '[Travel Enthusiast](https://www.instagram.com/travelenthusiast/)', - }, - ] - - test.each(markdownTestCases)('$page: should generate correct markdown', ({ page, info, url, expected }) => { - const buildMarkdown = siteConfigs.instagram.pages[page].buildMarkdown - expect(buildMarkdown(info, url)).toBe(expected) - }) -}) diff --git a/src/content/linkedin.test.js b/src/content/linkedin.test.js deleted file mode 100644 index bc690d2..0000000 --- a/src/content/linkedin.test.js +++ /dev/null @@ -1,47 +0,0 @@ -import siteConfigs from './config' - -describe('LinkedIn URL pattern tests', () => { - const testCases = [ - { page: 'profile', url: 'https://www.linkedin.com/in/username/', shouldMatch: true }, - { page: 'company', url: 'https://www.linkedin.com/company/companyname/', shouldMatch: true }, - { page: 'pulse', url: 'https://www.linkedin.com/pulse/article-title/', shouldMatch: true }, - { page: 'profile', url: 'https://www.linkedin.com/feed/', shouldMatch: false }, - ] - - test.each(testCases)('$page: $url should ${shouldMatch ? "match" : "not match"}', ({ page, url, shouldMatch }) => { - const pattern = siteConfigs.linkedin.pages[page].urlPattern - if (shouldMatch) { - expect(url).toMatch(pattern) - } else { - expect(url).not.toMatch(pattern) - } - }) -}) - -describe('LinkedIn markdown generator tests', () => { - const markdownTestCases = [ - { - page: 'profile', - info: { name: 'John Doe', headline: 'Software Engineer' }, - url: 'https://www.linkedin.com/in/johndoe/', - expected: '[John Doe](https://www.linkedin.com/in/johndoe/) - Software Engineer', - }, - { - page: 'company', - info: { name: 'Tech Corp', about: 'Leading technology company' }, - url: 'https://www.linkedin.com/company/techcorp/', - expected: '[Tech Corp](https://www.linkedin.com/company/techcorp/) - Leading technology company', - }, - { - page: 'pulse', - info: { title: 'The Future of AI', author: 'Jane Smith', date: 'May 1, 2023' }, - url: 'https://www.linkedin.com/pulse/future-ai-jane-smith/', - expected: '[The Future of AI](https://www.linkedin.com/pulse/future-ai-jane-smith/)\nBy Jane Smith | May 1, 2023', - }, - ] - - test.each(markdownTestCases)('$page: should generate correct markdown', ({ page, info, url, expected }) => { - const buildMarkdown = siteConfigs.linkedin.pages[page].buildMarkdown - expect(buildMarkdown(info, url)).toBe(expected) - }) -}) diff --git a/src/content/test/github.test.js b/src/content/test/github.test.js new file mode 100644 index 0000000..61285a2 --- /dev/null +++ b/src/content/test/github.test.js @@ -0,0 +1,83 @@ +import { runUrlPatternTests, runMarkdownGeneratorTests } from './testUtils' + +const urlPatternTestCases = [ + { page: 'pr', url: 'https://github.com/user/repo/pull/123', shouldMatch: true }, + { page: 'issue', url: 'https://github.com/user/repo/issues/456', shouldMatch: true }, + { page: 'discussion', url: 'https://github.com/user/repo/discussions/789', shouldMatch: true }, + { page: 'repo', url: 'https://github.com/user/repo', shouldMatch: true }, + { page: 'user', url: 'https://github.com/username', shouldMatch: true }, + { page: 'release', url: 'https://github.com/user/repo/releases/tag/v1.0.0', shouldMatch: true }, + { page: 'commit', url: 'https://github.com/user/repo/commit/1234567890123456789012345678901234567890', shouldMatch: true }, + { page: 'pr', url: 'https://github.com/user/repo', shouldMatch: false }, + { page: 'actions', url: 'https://github.com/jonfriesen/quickcite/actions/runs/10476888027', shouldMatch: true }, + { page: 'actions', url: 'https://github.com/octocat/Hello-World/actions/runs/12345678', shouldMatch: true }, + { page: 'actions', url: 'https://github.com/octocat/Hello-World/actions', shouldMatch: false }, + { page: 'actions', url: 'https://github.com/octocat/Hello-World/actions/runs/abcdefgh', shouldMatch: false }, + { page: 'actions', url: 'https://github.com/octocat/Hello-World/actions/runs/abcdefgh/job/12345678', shouldMatch: false }, +] + +const markdownTestCases = [ + { + page: 'pr', + info: { number: '#123', title: 'Add new feature' }, + url: 'https://github.com/user/repo/pull/123', + expected: '[#123: Add new feature](https://github.com/user/repo/pull/123)', + }, + { + page: 'issue', + info: { number: '#456', title: 'Fix bug in login' }, + url: 'https://github.com/user/repo/issues/456', + expected: '[#456: Fix bug in login](https://github.com/user/repo/issues/456)', + }, + { + page: 'discussion', + info: { number: '#789', title: 'Propose new architecture' }, + url: 'https://github.com/user/repo/discussions/789', + expected: '[#789: Propose new architecture](https://github.com/user/repo/discussions/789)', + }, + { + page: 'repo', + info: { title: 'user/repo', description: 'A cool project' }, + url: 'https://github.com/user/repo', + expected: '[user/repo](https://github.com/user/repo) - A cool project', + }, + { + page: 'user', + info: { name: 'John Doe', bio: 'Software Developer' }, + url: 'https://github.com/johndoe', + expected: '[John Doe](https://github.com/johndoe) - Software Developer', + }, + { + page: 'release', + info: { title: 'v1.0.0: First Release', date: '2023-05-01T00:00:00Z' }, + url: 'https://github.com/user/repo/releases/tag/v1.0.0', + expected: '[v1.0.0: First Release](https://github.com/user/repo/releases/tag/v1.0.0) - Released on ' + new Date('2023-05-01T00:00:00Z').toLocaleDateString(), + }, + { + page: 'commit', + info: { title: 'Update README.md', hash: '1234567890abcdef', author: 'John Doe', date: '2023-05-01T00:00:00Z' }, + url: 'https://github.com/user/repo/commit/1234567890abcdef', + expected: '[(1234567) - Update README.md](https://github.com/user/repo/commit/1234567890abcdef)\nBy John Doe on ' + new Date('2023-05-01T00:00:00Z').toLocaleString(), + }, + { + page: 'actions', + info: { repoOwner: 'jonfriesen', repoName: 'quickcite', workflowName: 'CI', runNumber: '#1234', runStatus: 'Success', statusEmoji: '✅' }, + url: 'https://github.com/jonfriesen/quickcite/actions/runs/10476888027', + expected: '[jonfriesen/quickcite: CI #1234 ✅ (Success)](https://github.com/jonfriesen/quickcite/actions/runs/10476888027)', + }, + { + page: 'actions', + info: { repoOwner: 'octocat', repoName: 'Hello-World', workflowName: 'Build', runNumber: '#5678', runStatus: 'Failure', statusEmoji: '❌' }, + url: 'https://github.com/octocat/Hello-World/actions/runs/12345678', + expected: '[octocat/Hello-World: Build #5678 ❌ (Failure)](https://github.com/octocat/Hello-World/actions/runs/12345678)', + }, + { + page: 'actions', + info: { repoOwner: 'test', repoName: 'repo', workflowName: 'Deploy', runNumber: '#9012', runStatus: 'In progress', statusEmoji: '🔄' }, + url: 'https://github.com/test/repo/actions/runs/90123456', + expected: '[test/repo: Deploy #9012 🔄 (In progress)](https://github.com/test/repo/actions/runs/90123456)', + }, +] + +runUrlPatternTests('github', urlPatternTestCases) +runMarkdownGeneratorTests('github', markdownTestCases) diff --git a/src/content/test/instagram.test.js b/src/content/test/instagram.test.js new file mode 100644 index 0000000..0059dd1 --- /dev/null +++ b/src/content/test/instagram.test.js @@ -0,0 +1,18 @@ +import { runUrlPatternTests, runMarkdownGeneratorTests } from './testUtils' + +const urlPatternTestCases = [ + { page: 'profile', url: 'https://www.instagram.com/username/', shouldMatch: true }, + { page: 'profile', url: 'https://www.instagram.com/p/123456/', shouldMatch: false }, +] + +const markdownTestCases = [ + { + page: 'profile', + info: { name: 'Travel Enthusiast' }, + url: 'https://www.instagram.com/travelenthusiast/', + expected: '[Travel Enthusiast](https://www.instagram.com/travelenthusiast/)', + }, +] + +runUrlPatternTests('instagram', urlPatternTestCases) +runMarkdownGeneratorTests('instagram', markdownTestCases) diff --git a/src/content/test/linkedin.test.js b/src/content/test/linkedin.test.js new file mode 100644 index 0000000..290c7d2 --- /dev/null +++ b/src/content/test/linkedin.test.js @@ -0,0 +1,32 @@ +import { runUrlPatternTests, runMarkdownGeneratorTests } from './testUtils' + +const urlPatternTestCases = [ + { page: 'profile', url: 'https://www.linkedin.com/in/username/', shouldMatch: true }, + { page: 'company', url: 'https://www.linkedin.com/company/companyname/', shouldMatch: true }, + { page: 'pulse', url: 'https://www.linkedin.com/pulse/article-title/', shouldMatch: true }, + { page: 'profile', url: 'https://www.linkedin.com/feed/', shouldMatch: false }, +] + +const markdownTestCases = [ + { + page: 'profile', + info: { name: 'John Doe', headline: 'Software Engineer' }, + url: 'https://www.linkedin.com/in/johndoe/', + expected: '[John Doe](https://www.linkedin.com/in/johndoe/) - Software Engineer', + }, + { + page: 'company', + info: { name: 'Tech Corp', about: 'Leading technology company' }, + url: 'https://www.linkedin.com/company/techcorp/', + expected: '[Tech Corp](https://www.linkedin.com/company/techcorp/) - Leading technology company', + }, + { + page: 'pulse', + info: { title: 'The Future of AI', author: 'Jane Smith', date: 'May 1, 2023' }, + url: 'https://www.linkedin.com/pulse/future-ai-jane-smith/', + expected: '[The Future of AI](https://www.linkedin.com/pulse/future-ai-jane-smith/)\nBy Jane Smith | May 1, 2023', + }, +] + +runUrlPatternTests('linkedin', urlPatternTestCases) +runMarkdownGeneratorTests('linkedin', markdownTestCases) diff --git a/src/content/test/testUtils.js b/src/content/test/testUtils.js new file mode 100644 index 0000000..b73c723 --- /dev/null +++ b/src/content/test/testUtils.js @@ -0,0 +1,32 @@ +import siteConfigs from '../config' + +export function runUrlPatternTests(siteName, testCases) { + describe(`${siteName} URL pattern tests`, () => { + test.each(testCases)('$page: $url should ${shouldMatch ? "match" : "not match"}', ({ page, url, shouldMatch }) => { + const pattern = siteConfigs[siteName].pages[page].urlPattern + if (shouldMatch) { + expect(url).toMatch(pattern) + } else { + expect(url).not.toMatch(pattern) + } + }) + }) +} + +export function runMarkdownGeneratorTests(siteName, markdownTestCases) { + describe(`${siteName} markdown generator tests`, () => { + test.each(markdownTestCases)('$page: should generate correct markdown', ({ page, info, url, expected }) => { + const buildMarkdown = siteConfigs[siteName].pages[page].buildMarkdown + expect(buildMarkdown(info, url)).toBe(expected) + }) + }) +} + +export function runPlaintextGeneratorTests(siteName, plaintextTestCases) { + describe(`${siteName} plaintext generator tests`, () => { + test.each(plaintextTestCases)('$page: should generate correct plaintext', ({ page, info, url, expected }) => { + const buildPlaintext = siteConfigs[siteName].pages[page].buildPlaintext + expect(buildPlaintext(info, url)).toBe(expected) + }) + }) +} diff --git a/src/content/test/trello.test.js b/src/content/test/trello.test.js new file mode 100644 index 0000000..e4ac86f --- /dev/null +++ b/src/content/test/trello.test.js @@ -0,0 +1,42 @@ +import { runUrlPatternTests, runMarkdownGeneratorTests, runPlaintextGeneratorTests } from './testUtils' + +const urlPatternTestCases = [ + { page: 'board', url: 'https://trello.com/b/F8vdp5Mo', shouldMatch: true }, + { page: 'board', url: 'https://trello.com/b/sZr0YugI/awesome-stuff', shouldMatch: true }, + { page: 'board', url: 'https://trello.com/c/abcdefgh', shouldMatch: false }, + { page: 'board', url: 'https://trello.com/b/F8vdp5Mo/subfolder/not-valid', shouldMatch: false }, +] + +const markdownTestCases = [ + { + page: 'board', + info: { boardName: 'Project Roadmap' }, + url: 'https://trello.com/b/F8vdp5Mo', + expected: '[Project Roadmap](https://trello.com/b/F8vdp5Mo)', + }, + { + page: 'board', + info: { boardName: 'Team Tasks' }, + url: 'https://trello.com/b/sZr0YugI/team-tasks', + expected: '[Team Tasks](https://trello.com/b/sZr0YugI/team-tasks)', + }, +] + +const plaintextTestCases = [ + { + page: 'board', + info: { boardName: 'Project Roadmap' }, + url: 'https://trello.com/b/F8vdp5Mo', + expected: 'Project Roadmap - https://trello.com/b/F8vdp5Mo', + }, + { + page: 'board', + info: { boardName: 'Team Tasks' }, + url: 'https://trello.com/b/sZr0YugI/team-tasks', + expected: 'Team Tasks - https://trello.com/b/sZr0YugI/team-tasks', + }, +] + +runUrlPatternTests('trello', urlPatternTestCases) +runMarkdownGeneratorTests('trello', markdownTestCases) +runPlaintextGeneratorTests('trello', plaintextTestCases) diff --git a/src/content/trello.test.js b/src/content/trello.test.js deleted file mode 100644 index 4b4317b..0000000 --- a/src/content/trello.test.js +++ /dev/null @@ -1,63 +0,0 @@ -import siteConfigs from './config' - -describe('Trello URL pattern tests', () => { - const testCases = [ - { page: 'board', url: 'https://trello.com/b/F8vdp5Mo', shouldMatch: true }, - { page: 'board', url: 'https://trello.com/b/sZr0YugI/awesome-stuff', shouldMatch: true }, - { page: 'board', url: 'https://trello.com/c/abcdefgh', shouldMatch: false }, - { page: 'board', url: 'https://trello.com/b/F8vdp5Mo/subfolder/not-valid', shouldMatch: false }, - ] - - test.each(testCases)('$page: $url should ${shouldMatch ? "match" : "not match"}', ({ page, url, shouldMatch }) => { - const pattern = siteConfigs.trello.pages[page].urlPattern - if (shouldMatch) { - expect(url).toMatch(pattern) - } else { - expect(url).not.toMatch(pattern) - } - }) -}) - -describe('Trello markdown generator tests', () => { - const markdownTestCases = [ - { - page: 'board', - info: { boardName: 'Project Roadmap' }, - url: 'https://trello.com/b/F8vdp5Mo', - expected: '[Project Roadmap](https://trello.com/b/F8vdp5Mo)', - }, - { - page: 'board', - info: { boardName: 'Team Tasks' }, - url: 'https://trello.com/b/sZr0YugI/team-tasks', - expected: '[Team Tasks](https://trello.com/b/sZr0YugI/team-tasks)', - }, - ] - - test.each(markdownTestCases)('$page: should generate correct markdown', ({ page, info, url, expected }) => { - const buildMarkdown = siteConfigs.trello.pages[page].buildMarkdown - expect(buildMarkdown(info, url)).toBe(expected) - }) -}) - -describe('Trello plaintext generator tests', () => { - const plaintextTestCases = [ - { - page: 'board', - info: { boardName: 'Project Roadmap' }, - url: 'https://trello.com/b/F8vdp5Mo', - expected: 'Project Roadmap - https://trello.com/b/F8vdp5Mo', - }, - { - page: 'board', - info: { boardName: 'Team Tasks' }, - url: 'https://trello.com/b/sZr0YugI/team-tasks', - expected: 'Team Tasks - https://trello.com/b/sZr0YugI/team-tasks', - }, - ] - - test.each(plaintextTestCases)('$page: should generate correct plaintext', ({ page, info, url, expected }) => { - const buildPlaintext = siteConfigs.trello.pages[page].buildPlaintext - expect(buildPlaintext(info, url)).toBe(expected) - }) -})