- 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。
71 lines
1.7 KiB
Go
Executable File
71 lines
1.7 KiB
Go
Executable File
package style_test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/marqdo/marqdo/plugins/web/internal/style"
|
|
)
|
|
|
|
func TestStyleSimple(t *testing.T) {
|
|
css, err := style.Style(map[string]any{
|
|
"name": "card",
|
|
"table": []any{
|
|
map[string]any{"选择器": ".card", "属性": "color", "值": "navy"},
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(css, ".card {") || !strings.Contains(css, "color: navy;") {
|
|
t.Fatalf("%q", css)
|
|
}
|
|
}
|
|
|
|
func TestStyleStrictKeepsQuotedSlash(t *testing.T) {
|
|
css, err := style.Style(map[string]any{
|
|
"name": "t",
|
|
"strict": true,
|
|
"table": []any{
|
|
map[string]any{"选择器": ".box", "属性": "grid-column", "值": "1 / 5"},
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(css, "1 / 5") {
|
|
t.Fatalf("missing quoted value: %q", css)
|
|
}
|
|
}
|
|
|
|
func TestStyleStrictAllowsNumeric(t *testing.T) {
|
|
css, err := style.Style(map[string]any{
|
|
"name": "x",
|
|
"strict": true,
|
|
"table": []any{
|
|
map[string]any{"选择器": ".x", "属性": "z-index", "值": float64(20)},
|
|
map[string]any{"选择器": ".y", "属性": "opacity", "值": float64(0.5)},
|
|
map[string]any{"选择器": ".z", "属性": "font-weight", "值": float64(700)},
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("numeric CSS must not be suspicious: %v", err)
|
|
}
|
|
if !strings.Contains(css, "z-index: 20") || !strings.Contains(css, "opacity: 0.5") {
|
|
t.Fatalf("%q", css)
|
|
}
|
|
}
|
|
|
|
func TestStyleStrictRejectsBoolean(t *testing.T) {
|
|
_, err := style.Style(map[string]any{
|
|
"name": "x",
|
|
"strict": true,
|
|
"table": []any{
|
|
map[string]any{"选择器": ".x", "属性": "display", "值": true},
|
|
},
|
|
})
|
|
if err == nil || !strings.Contains(err.Error(), "suspicious") {
|
|
t.Fatalf("err=%v", err)
|
|
}
|
|
}
|