- CHANGELOG.md:v2.8.0 条目(中英双语); - README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明); - doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制); - skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/ require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过); - 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
73 lines
1.8 KiB
Go
Executable File
73 lines
1.8 KiB
Go
Executable File
package assets
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestImagesBasic(t *testing.T) {
|
|
table := []any{
|
|
map[string]any{"源": "/a.png", "替代": "A", "类": "logo", "加载": "eager"},
|
|
}
|
|
h := MakeImagesHTML(table)
|
|
if !strings.Contains(h, "mq-images") {
|
|
t.Fatalf("missing mq-images: %s", h)
|
|
}
|
|
if !strings.Contains(h, `src="/a.png"`) {
|
|
t.Fatalf("missing src: %s", h)
|
|
}
|
|
if !strings.Contains(h, `loading="eager"`) {
|
|
t.Fatalf("missing loading: %s", h)
|
|
}
|
|
if !strings.Contains(h, `class="mq-img logo"`) {
|
|
t.Fatalf("missing class: %s", h)
|
|
}
|
|
}
|
|
|
|
func TestHeadScriptAndIcon(t *testing.T) {
|
|
table := []any{
|
|
map[string]any{"关系": "icon", "地址": "/favicon.ico", "类型": "image/x-icon"},
|
|
map[string]any{"关系": "script", "地址": "/static/a.js"},
|
|
}
|
|
h := MakeHeadHTML(table)
|
|
if !strings.Contains(h, `rel="icon"`) {
|
|
t.Fatalf("missing icon: %s", h)
|
|
}
|
|
if !strings.Contains(h, `<script src="/static/a.js"></script>`) {
|
|
t.Fatalf("missing script: %s", h)
|
|
}
|
|
if strings.Contains(h, " defer") {
|
|
t.Fatalf("unexpected defer: %s", h)
|
|
}
|
|
}
|
|
|
|
func TestHeadDeferVersion(t *testing.T) {
|
|
table := []any{
|
|
map[string]any{"关系": "script", "地址": "/static/a.js", "推迟": true, "版本": "3"},
|
|
}
|
|
links := AsHeadLinks(table)
|
|
h := RenderHeadLinksWithVersion(links, "2026-09-04")
|
|
if !strings.Contains(h, `<script defer src="/static/a.js?v=3"></script>`) {
|
|
t.Fatalf("defer+version: %s", h)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeIcons(t *testing.T) {
|
|
table := []any{
|
|
map[string]any{
|
|
"path": "web-fixtures/public/favicon.png", "rel": "icon",
|
|
"type": "image/png", "sizes": "32x32", "url": "/favicon.ico",
|
|
},
|
|
}
|
|
icons, head, routes := NormalizeIcons(table)
|
|
if len(icons) != 1 {
|
|
t.Fatalf("icons=%d", len(icons))
|
|
}
|
|
if len(head) == 0 {
|
|
t.Fatal("expected site head")
|
|
}
|
|
if len(routes) == 0 {
|
|
t.Fatal("expected routes")
|
|
}
|
|
}
|