3const fs = require("fs");
4const path = require("path");
6const cmsFile = path.resolve(__dirname, "../../../js/lib/cms.js");
7const source = fs.readFileSync(cmsFile, "utf8");
8const match = source.match(/function mediaSlotMatchesBox\([^)]*\) \{[\s\S]*?\n \}/);
11 throw new Error("mediaSlotMatchesBox wurde in cms.js nicht gefunden.");
14const mediaSlotMatchesBox = Function(`"use strict"; return (${match[0]});`)();
16 ["gallery", "gallery", "all", true, "Gallery-Zuordnung in Gallery"],
17 ["gallery", "shop", "all", true, "Shop-Zuordnung in Gallery"],
18 ["gallery", "inline", "all", false, "Inline-Zuordnung nicht in Gallery"],
19 ["inline", "shop", "all", false, "Shop-Zuordnung nicht im Text"],
20 ["shop", "shop", "all", true, "Shop-Zuordnung in eigenem Shop-Bereich"],
21 ["all", "shop", "gallery", false, "Gallery-Filter bleibt im Medienbrowser exakt"],
22 ["all", "shop", "all", true, "Alle zeigt Shop-Zuordnung"],
23 ["custom", "hero", "all", false, "Hero bleibt aus normalen Listen ausgeblendet"],
26for (const [boxSlot, slot, filter, expected, label] of cases) {
27 const actual = mediaSlotMatchesBox(boxSlot, slot, filter);
28 if (actual !== expected) {
29 throw new Error(`${label}: erwartet ${expected}, erhalten ${actual}`);
33console.log("OK cms_shop_gallery_test");