Fix tests
This commit is contained in:
parent
3785d51468
commit
b2741e1b6d
6 changed files with 20 additions and 19 deletions
|
@ -9,10 +9,11 @@ export class ExtractImages extends Conversion<LayoutConfigJson, string[]> {
|
|||
super("Extract all images from a layoutConfig using the meta paths");
|
||||
}
|
||||
|
||||
convert(json: LayoutConfigJson, context: string): { result: string[] } {
|
||||
convert(json: LayoutConfigJson, context: string): { result: string[], errors: string[] } {
|
||||
const paths = metapaths["default"] ?? metapaths
|
||||
const trpaths = tagrenderingmetapaths["default"] ?? tagrenderingmetapaths
|
||||
const allFoundImages = []
|
||||
const errors = []
|
||||
for (const metapath of paths) {
|
||||
if (metapath.typeHint === undefined) {
|
||||
continue
|
||||
|
@ -34,7 +35,13 @@ export class ExtractImages extends Conversion<LayoutConfigJson, string[]> {
|
|||
if (trpath.typeHint !== "rendered") {
|
||||
continue
|
||||
}
|
||||
Utils.CollectPath(trpath.path, foundImage, allFoundImages)
|
||||
const fromPath = Utils.CollectPath(trpath.path, foundImage)
|
||||
for (const img of fromPath) {
|
||||
if (typeof img !== "string") {
|
||||
errors.push("Found an image path that is not a path at " + context + "." + metapath.path.join(".") + ": " + JSON.stringify(img))
|
||||
}
|
||||
}
|
||||
allFoundImages.push(...fromPath.filter(i => typeof i === "string"))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,9 +51,9 @@ export class ExtractImages extends Conversion<LayoutConfigJson, string[]> {
|
|||
}
|
||||
}
|
||||
|
||||
const splitParts = [].concat(...allFoundImages.map(img => img.split(";")))
|
||||
const splitParts = [].concat(...Utils.NoNull(allFoundImages).map(img => img.split(";")))
|
||||
.map(img => img.split(":")[0])
|
||||
return {result: Utils.Dedup(splitParts)};
|
||||
return {result: Utils.Dedup(splitParts), errors};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ export default class LayoutConfig {
|
|||
this.credits = json.credits;
|
||||
this.version = json.version;
|
||||
this.language = json.mustHaveLanguage ?? Array.from(Object.keys(json.title));
|
||||
this.usedImages =Array.from( new ExtractImages().convertStrict(json, "while extracting the images")).sort()
|
||||
this.usedImages =Array.from( new ExtractImages().convertStrict(json, "while extracting the images of "+json.id+" "+context??"")).sort()
|
||||
{
|
||||
if (typeof json.title === "string") {
|
||||
throw `The title of a theme should always be a translation, as it sets the corresponding languages (${context}.title). The themenID is ${this.id}; the offending object is ${JSON.stringify(json.title)} which is a ${typeof json.title})`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue