diff options
Diffstat (limited to 'parser')
-rw-r--r-- | parser/parse_frontmatter_test.go | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/parser/parse_frontmatter_test.go b/parser/parse_frontmatter_test.go index babad351f..cbf6c1bc5 100644 --- a/parser/parse_frontmatter_test.go +++ b/parser/parse_frontmatter_test.go @@ -26,20 +26,20 @@ import ( ) var ( - CONTENT_NO_FRONTMATTER = "a page with no front matter" - CONTENT_WITH_FRONTMATTER = "---\ntitle: front matter\n---\nContent with front matter" - CONTENT_HTML_NODOCTYPE = "<html>\n\t<body>\n\t</body>\n</html>" - CONTENT_HTML_WITHDOCTYPE = "<!doctype html><html><body></body></html>" - CONTENT_HTML_WITH_FRONTMATTER = "---\ntitle: front matter\n---\n<!doctype><html><body></body></html>" - CONTENT_LWS_HTML = " <html><body></body></html>" - CONTENT_LWS_LF_HTML = "\n<html><body></body></html>" - CONTENT_INCOMPLETE_END_FM_DELIM = "---\ntitle: incomplete end fm delim\n--\nincomplete frontmatter delim" - CONTENT_MISSING_END_FM_DELIM = "---\ntitle: incomplete end fm delim\nincomplete frontmatter delim" - CONTENT_SLUG_WORKING = "---\ntitle: slug doc 2\nslug: slug-doc-2\n\n---\nslug doc 2 content" - CONTENT_SLUG_WORKING_VARIATION = "---\ntitle: slug doc 3\nslug: slug-doc 3\n---\nslug doc 3 content" - CONTENT_SLUG_BUG = "---\ntitle: slug doc 2\nslug: slug-doc-2\n---\nslug doc 2 content" - CONTENT_WITH_JS_FM = "{\n \"categories\": \"d\",\n \"tags\": [\n \"a\", \n \"b\", \n \"c\"\n ]\n}\nJSON Front Matter with tags and categories" - CONTENT_WITH_JS_LOOSE_FM = "{\n \"categories\": \"d\"\n \"tags\": [\n \"a\" \n \"b\" \n \"c\"\n ]\n}\nJSON Front Matter with tags and categories" + contentNoFrontmatter = "a page with no front matter" + contentWithFrontmatter = "---\ntitle: front matter\n---\nContent with front matter" + contentHTMLNoDoctype = "<html>\n\t<body>\n\t</body>\n</html>" + contentHTMLWithDoctype = "<!doctype html><html><body></body></html>" + contentHTMLWithFrontmatter = "---\ntitle: front matter\n---\n<!doctype><html><body></body></html>" + contentHTML = " <html><body></body></html>" + contentLinefeedAndHTML = "\n<html><body></body></html>" + contentIncompleteEndFrontmatterDelim = "---\ntitle: incomplete end fm delim\n--\nincomplete frontmatter delim" + contentMissingEndFrontmatterDelim = "---\ntitle: incomplete end fm delim\nincomplete frontmatter delim" + contentSlugWorking = "---\ntitle: slug doc 2\nslug: slug-doc-2\n\n---\nslug doc 2 content" + contentSlugWorkingVariation = "---\ntitle: slug doc 3\nslug: slug-doc 3\n---\nslug doc 3 content" + contentSlugBug = "---\ntitle: slug doc 2\nslug: slug-doc-2\n---\nslug doc 2 content" + contentSlugWithJSONFrontMatter = "{\n \"categories\": \"d\",\n \"tags\": [\n \"a\", \n \"b\", \n \"c\"\n ]\n}\nJSON Front Matter with tags and categories" + contentWithJSONLooseFrontmatter = "{\n \"categories\": \"d\"\n \"tags\": [\n \"a\" \n \"b\" \n \"c\"\n ]\n}\nJSON Front Matter with tags and categories" ) var lineEndings = []string{"\n", "\r\n"} @@ -56,8 +56,8 @@ func TestDegenerateCreatePageFrom(t *testing.T) { tests := []struct { content string }{ - {CONTENT_MISSING_END_FM_DELIM}, - {CONTENT_INCOMPLETE_END_FM_DELIM}, + {contentMissingEndFrontmatterDelim}, + {contentIncompleteEndFrontmatterDelim}, } for _, test := range tests { @@ -108,18 +108,18 @@ func TestStandaloneCreatePageFrom(t *testing.T) { bodycontent string }{ - {CONTENT_NO_FRONTMATTER, true, true, "", "a page with no front matter"}, - {CONTENT_WITH_FRONTMATTER, true, false, "---\ntitle: front matter\n---\n", "Content with front matter"}, - {CONTENT_HTML_NODOCTYPE, false, true, "", "<html>\n\t<body>\n\t</body>\n</html>"}, - {CONTENT_HTML_WITHDOCTYPE, false, true, "", "<!doctype html><html><body></body></html>"}, - {CONTENT_HTML_WITH_FRONTMATTER, true, false, "---\ntitle: front matter\n---\n", "<!doctype><html><body></body></html>"}, - {CONTENT_LWS_HTML, false, true, "", "<html><body></body></html>"}, - {CONTENT_LWS_LF_HTML, false, true, "", "<html><body></body></html>"}, - {CONTENT_WITH_JS_FM, true, false, "{\n \"categories\": \"d\",\n \"tags\": [\n \"a\", \n \"b\", \n \"c\"\n ]\n}", "JSON Front Matter with tags and categories"}, - {CONTENT_WITH_JS_LOOSE_FM, true, false, "{\n \"categories\": \"d\"\n \"tags\": [\n \"a\" \n \"b\" \n \"c\"\n ]\n}", "JSON Front Matter with tags and categories"}, - {CONTENT_SLUG_WORKING, true, false, "---\ntitle: slug doc 2\nslug: slug-doc-2\n\n---\n", "slug doc 2 content"}, - {CONTENT_SLUG_WORKING_VARIATION, true, false, "---\ntitle: slug doc 3\nslug: slug-doc 3\n---\n", "slug doc 3 content"}, - {CONTENT_SLUG_BUG, true, false, "---\ntitle: slug doc 2\nslug: slug-doc-2\n---\n", "slug doc 2 content"}, + {contentNoFrontmatter, true, true, "", "a page with no front matter"}, + {contentWithFrontmatter, true, false, "---\ntitle: front matter\n---\n", "Content with front matter"}, + {contentHTMLNoDoctype, false, true, "", "<html>\n\t<body>\n\t</body>\n</html>"}, + {contentHTMLWithDoctype, false, true, "", "<!doctype html><html><body></body></html>"}, + {contentHTMLWithFrontmatter, true, false, "---\ntitle: front matter\n---\n", "<!doctype><html><body></body></html>"}, + {contentHTML, false, true, "", "<html><body></body></html>"}, + {contentLinefeedAndHTML, false, true, "", "<html><body></body></html>"}, + {contentSlugWithJSONFrontMatter, true, false, "{\n \"categories\": \"d\",\n \"tags\": [\n \"a\", \n \"b\", \n \"c\"\n ]\n}", "JSON Front Matter with tags and categories"}, + {contentWithJSONLooseFrontmatter, true, false, "{\n \"categories\": \"d\"\n \"tags\": [\n \"a\" \n \"b\" \n \"c\"\n ]\n}", "JSON Front Matter with tags and categories"}, + {contentSlugWorking, true, false, "---\ntitle: slug doc 2\nslug: slug-doc-2\n\n---\n", "slug doc 2 content"}, + {contentSlugWorkingVariation, true, false, "---\ntitle: slug doc 3\nslug: slug-doc 3\n---\n", "slug doc 3 content"}, + {contentSlugBug, true, false, "---\ntitle: slug doc 2\nslug: slug-doc-2\n---\n", "slug doc 2 content"}, } for _, test := range tests { |