dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
cms_shop_gallery_test.js
Go to the documentation of this file.
1"use strict";
2
3const fs = require("fs");
4const path = require("path");
5
6const cmsFile = path.resolve(__dirname, "../../../js/lib/cms.js");
7const source = fs.readFileSync(cmsFile, "utf8");
8const match = source.match(/function mediaSlotMatchesBox\‍([^)]*\‍) \{[\s\S]*?\n \}/);
9
10if (!match) {
11 throw new Error("mediaSlotMatchesBox wurde in cms.js nicht gefunden.");
12}
13
14const mediaSlotMatchesBox = Function(`"use strict"; return (${match[0]});`)();
15const cases = [
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"],
24];
25
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}`);
30 }
31}
32
33console.log("OK cms_shop_gallery_test");