import { describe, it, expect } from 'vitest'; import fs from 'fs'; import path from 'path'; import { defaultLocations, minorLocations } from '../lib/map-data'; describe('Task 12 TDD - Bohrtechnik and Reference Links', () => { const deHomePath = path.join(process.cwd(), 'content', 'de', 'home.mdx'); const enHomePath = path.join(process.cwd(), 'content', 'en', 'home.mdx'); it('should verify E-TIB Bohrtechnik GmbH has the correct page link in DE and EN home.mdx', () => { const deContent = fs.readFileSync(deHomePath, 'utf8'); const enContent = fs.readFileSync(enHomePath, 'utf8'); // Assert that E-TIB Bohrtechnik GmbH has url: "/de/bohrtechnik" in German content expect(deContent).toContain('title: "E-TIB Bohrtechnik GmbH"'); // We expect it to have the url parameter added const bohrtechnikDeBlock = deContent.substring(deContent.indexOf('title: "E-TIB Bohrtechnik GmbH"')); const urlDeIndex = bohrtechnikDeBlock.indexOf('url:'); const nextItemDeIndex = bohrtechnikDeBlock.indexOf('title:', 10); // Ensure "url:" exists within the E-TIB Bohrtechnik block and points to "/de/bohrtechnik" expect(deContent).toMatch(/title:\s*"E-TIB Bohrtechnik GmbH"[\s\S]*?url:\s*["']\/de\/bohrtechnik["']/); // Assert that E-TIB Bohrtechnik GmbH has url: "/en/drilling-technology" in English content expect(enContent).toContain('title: "E-TIB Bohrtechnik GmbH"'); expect(enContent).toMatch(/title:\s*"E-TIB Bohrtechnik GmbH"[\s\S]*?url:\s*["']\/en\/drilling-technology["']/); }); it('should verify that all reference projects in map-data have no href links', () => { // Check that all minorLocations of type 'minor_node' have href undefined // since all projects were downgraded to minor nodes without links. const projects = minorLocations.filter(loc => loc.type === 'minor_node'); expect(projects.length).toBeGreaterThan(0); projects.forEach(project => { expect(project.href).toBeUndefined(); }); }); });