package shot import "testing" func TestPreviewURLComposesQuery(t *testing.T) { got := PreviewURL("https://showcase.localdev.blockninjacms.com", "/", "gotham") want := "https://showcase.localdev.blockninjacms.com/?preview_template=gotham" if got != want { t.Fatalf("PreviewURL = %q, want %q", got, want) } } func TestPreviewURLTrimsTrailingSlashHost(t *testing.T) { got := PreviewURL("https://showcase.localdev.blockninjacms.com/", "/", "noir") want := "https://showcase.localdev.blockninjacms.com/?preview_template=noir" if got != want { t.Fatalf("PreviewURL = %q, want %q", got, want) } } func TestPreviewURLNonRootSlug(t *testing.T) { got := PreviewURL("https://x.example.com", "/showcase", "lcars") want := "https://x.example.com/showcase?preview_template=lcars" if got != want { t.Fatalf("PreviewURL = %q, want %q", got, want) } }