motorino/internal/mdx/slug_test.go

43 lines
1.4 KiB
Go

// SPDX-License-Identifier: GPL-3.0-or-later
package mdx
import "testing"
// TestSlug checks the heading identifiers against the real manifesto headings
// (after the em dash rewrite) and ordinary headings.
func TestSlug(t *testing.T) {
tests := []struct {
heading string
want string
}{
{"01. Antifascist. No ambiguity.", "01"},
{"14. Meaning doesn't need a god", "14"},
{"01. Antifascisti. Senza ambiguità.", "01"},
{"Preamble: We don't ask permission to think", "preamble"},
{"Preambolo: Non chiediamo il permesso di pensare", "preamble"},
{"Preámbulo: No pedimos permiso", "preamble"},
{"Präambel", "preamble"},
{"Préambule", "preamble"},
{"Our commitments", "commitments"},
{"I nostri impegni", "commitments"},
{"Nuestros compromisos", "commitments"},
{"Unsere Verpflichtungen", "commitments"},
{"Nos engagements", "commitments"},
{"Epilogue: Free your mind", "epilogue"},
{"Epilogo: Libera la mente", "epilogue"},
{"Epílogo: Libera tu mente", "epilogue"},
{"Epilog", "epilogue"},
{"Épilogue", "epilogue"},
{"About this text", "about-this-text"},
{"Request an account", "request-an-account"},
{" Spaces & Symbols! ", "spaces-symbols"},
}
for _, tt := range tests {
t.Run(tt.heading, func(t *testing.T) {
if got := Slug(tt.heading); got != tt.want {
t.Errorf("Slug(%q) = %q, want %q", tt.heading, got, tt.want)
}
})
}
}