oficina / estilo Public

Check shared call styles against defined suite tokens

Paul Campbell pushed by paul@keymail.dev ce2a798571db445c198fe67765eef2fc3b810a8f parent 63070a8
1 file changed, +26 −0
  • callui/tokens_test.go +26 −0

CI passed — run details

diff --git a/callui/tokens_test.go b/callui/tokens_test.go
new file mode 100644
index 0000000..12b5fe8
--- /dev/null
+++ b/callui/tokens_test.go
@@ -0,0 +1,26 @@
+package callui
+
+import (
+ "amadan.net/oficina/estilo.git/theme"
+ "github.com/carlosframework/rastrillo/ui"
+ "regexp"
+ "testing"
+)
+
+// Mutation-checked: the former undefined --rst-border reference must fail.
+func TestCallStylesUseDefinedTokens(t *testing.T) {
+ definitions := map[string]bool{}
+ styles := append(append([]byte{}, ui.TokensCSS()...), theme.CSS()...)
+ for _, m := range regexp.MustCompile(`(--rst-[a-z0-9-]+)\s*:`).FindAllSubmatch(styles, -1) {
+ definitions[string(m[1])] = true
+ }
+ references := regexp.MustCompile(`var\(\s*(--rst-[a-z0-9-]+)`).FindAllSubmatch(CSS(), -1)
+ if len(references) == 0 {
+ t.Fatal("call token reference disappeared")
+ }
+ for _, m := range references {
+ if !definitions[string(m[1])] {
+ t.Fatal("call stylesheet uses undefined token", string(m[1]))
+ }
+ }
+}