Funktionen neu: Bilder für Entdecken aus Testdaten (Einbettungen auf Beispiel-Website)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9ca7900213
commit
c87c87e76b
6 files changed
+26
-1
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -1,6 +1,7 @@
|
|||||||
import { test } from 'node:test'
|
import { test } from 'node:test'
|
||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { readFileSync } from 'node:fs'
|
import { readFileSync, statSync, readdirSync, existsSync } from 'node:fs'
|
||||||
|
import sharp from 'sharp'
|
||||||
|
|
||||||
const lies = (pfad) => readFileSync(new URL(`../${pfad}`, import.meta.url), 'utf8')
|
const lies = (pfad) => readFileSync(new URL(`../${pfad}`, import.meta.url), 'utf8')
|
||||||
const ohneKommentare = (t) => t.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:])\/\/.*$/gm, '$1')
|
const ohneKommentare = (t) => t.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:])\/\/.*$/gm, '$1')
|
||||||
@@ -91,3 +92,27 @@ test('beide Module laden unter Node ohne DOM (kein Zugriff beim Import)', async
|
|||||||
test('Module der Funktionen: keine Hash-Namen außer den vorhandenen, kein Hash mit Großbuchstaben', () => {
|
test('Module der Funktionen: keine Hash-Namen außer den vorhandenen, kein Hash mit Großbuchstaben', () => {
|
||||||
for (const datei of JS) for (const m of ohneKommentare(lies(datei)).matchAll(/'#([A-Za-z-]+)/g)) assert.match(m[1], /^[a-z-]+$/, `${datei}: #${m[1]}`)
|
for (const datei of JS) for (const m of ohneKommentare(lies(datei)).matchAll(/'#([A-Za-z-]+)/g)) assert.match(m[1], /^[a-z-]+$/, `${datei}: #${m[1]}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Bilder: fünf webp-Dateien, 960×600, höchstens 120 KB; analyse.webp, falls da, ebenso', async () => {
|
||||||
|
const PFLICHT = ['news', 'termine', 'shop', 'unterkunft', 'zeiten']
|
||||||
|
const ordner = new URL('../public/neu/bilder/', import.meta.url)
|
||||||
|
assert.ok(existsSync(ordner), 'public/neu/bilder/ fehlt')
|
||||||
|
const da = readdirSync(ordner).sort()
|
||||||
|
for (const d of da) assert.ok([...PFLICHT, 'analyse'].map((k) => `${k}.webp`).includes(d), `unerwartete Datei ${d}`)
|
||||||
|
for (const key of PFLICHT) assert.ok(da.includes(`${key}.webp`), `${key}.webp fehlt`)
|
||||||
|
for (const d of da) {
|
||||||
|
const pfad = new URL(d, ordner).pathname
|
||||||
|
const meta = await sharp(pfad).metadata()
|
||||||
|
assert.deepEqual([meta.format, meta.width, meta.height], ['webp', 960, 600], d)
|
||||||
|
assert.ok(statSync(pfad).size <= 122880, `${d} größer als 120 KB`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test('Bilder: jede Bildadresse des Katalogs zeigt auf eine Datei unter public/neu/bilder/ (Testdaten)', async () => {
|
||||||
|
const { daten } = await import('./support/knFunktionenDaten.js')
|
||||||
|
for (const e of daten().katalog) {
|
||||||
|
const m = /^\/neu\/bilder\/([a-z0-9-]+)\.webp$/.exec(e.bild)
|
||||||
|
assert.ok(m, e.key)
|
||||||
|
if (e.key !== 'analyse') assert.ok(existsSync(new URL(`../public/neu/bilder/${m[1]}.webp`, import.meta.url)), `${e.key}: Bild fehlt`) // analyse.webp kommt mit P4 (VF2)
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in new issue
Block a user