-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(compat): verify that 'demo.adoc' renders as expected (#961)
Also, move all docs in `test/fixtures/pending` into `test/fixtures/supported` since they all pass now! (and rename dir to `test/compat`) Also, refactor (X)HTML matchers to support files and improve support for templates Fixes #960 Signed-off-by: Xavier Coulon <[email protected]>
- Loading branch information
Showing
57 changed files
with
2,029 additions
and
804 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ v1.0, March 22, 2020: Containment | |
{author} wrote this doc on {revdate}. | ||
` | ||
expected := `<!DOCTYPE html> | ||
expectedTmpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
@@ -51,22 +51,30 @@ v1.0, March 22, 2020: Containment | |
<div id="footer"> | ||
<div id="footer-text"> | ||
Version 1.0<br> | ||
Last updated {{.LastUpdated}} | ||
Last updated {{ .LastUpdated }} | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
` | ||
now := time.Now() | ||
Expect(RenderHTML(source, configuration.WithHeaderFooter(true), configuration.WithLastUpdated(now))).To(MatchHTMLTemplate(expected, now)) | ||
Expect(RenderHTML(source, | ||
configuration.WithHeaderFooter(true), | ||
configuration.WithLastUpdated(now), | ||
)).To(MatchHTMLTemplate(expectedTmpl, | ||
struct { | ||
LastUpdated string | ||
}{ | ||
LastUpdated: now.Format(configuration.LastUpdatedFormat), | ||
})) | ||
}) | ||
|
||
It("header with 2 authors and no revision", func() { | ||
source := `= Document Title | ||
John Foo Doe <[email protected]>; Jane Doe <[email protected]>` | ||
// top-level section is not rendered per-say, | ||
// but the section will be used to set the HTML page's <title> element | ||
expected := `<!DOCTYPE html> | ||
expectedTmpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
@@ -90,23 +98,30 @@ John Foo Doe <[email protected]>; Jane Doe <[email protected]>` | |
</div> | ||
<div id="footer"> | ||
<div id="footer-text"> | ||
Last updated {{.LastUpdated}} | ||
Last updated {{ .LastUpdated }} | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
` | ||
now := time.Now() | ||
Expect(RenderHTML(source, configuration.WithHeaderFooter(true), configuration.WithLastUpdated(now))). | ||
To(MatchHTMLTemplate(expected, now)) | ||
Expect(RenderHTML(source, | ||
configuration.WithHeaderFooter(true), | ||
configuration.WithLastUpdated(now), | ||
)).To(MatchHTMLTemplate(expectedTmpl, | ||
struct { | ||
LastUpdated string | ||
}{ | ||
LastUpdated: now.Format(configuration.LastUpdatedFormat), | ||
})) | ||
}) | ||
|
||
It("header with description", func() { | ||
source := `= Document Title | ||
:description: a description | ||
some content` | ||
expected := `<!DOCTYPE html> | ||
expectedTmpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
@@ -127,15 +142,22 @@ some content` | |
</div> | ||
<div id="footer"> | ||
<div id="footer-text"> | ||
Last updated {{.LastUpdated}} | ||
Last updated {{ .LastUpdated }} | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
` | ||
now := time.Now() | ||
Expect(RenderHTML(source, configuration.WithHeaderFooter(true), configuration.WithLastUpdated(now))). | ||
To(MatchHTMLTemplate(expected, now)) | ||
Expect(RenderHTML(source, | ||
configuration.WithHeaderFooter(true), | ||
configuration.WithLastUpdated(now), | ||
)).To(MatchHTMLTemplate(expectedTmpl, | ||
struct { | ||
LastUpdated string | ||
}{ | ||
LastUpdated: now.Format(configuration.LastUpdatedFormat), | ||
})) | ||
}) | ||
|
||
It("header with sotf-wrapped description", func() { | ||
|
@@ -148,7 +170,7 @@ Last updated {{.LastUpdated}} | |
{description}` | ||
|
||
expected := `<!DOCTYPE html> | ||
expectedTmpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
@@ -173,15 +195,22 @@ Last updated {{.LastUpdated}} | |
</div> | ||
<div id="footer"> | ||
<div id="footer-text"> | ||
Last updated {{.LastUpdated}} | ||
Last updated {{ .LastUpdated }} | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
` | ||
now := time.Now() | ||
Expect(RenderHTML(source, configuration.WithHeaderFooter(true), configuration.WithLastUpdated(now))). | ||
To(MatchHTMLTemplate(expected, now)) | ||
Expect(RenderHTML(source, | ||
configuration.WithHeaderFooter(true), | ||
configuration.WithLastUpdated(now), | ||
)).To(MatchHTMLTemplate(expectedTmpl, | ||
struct { | ||
LastUpdated string | ||
}{ | ||
LastUpdated: now.Format(configuration.LastUpdatedFormat), | ||
})) | ||
}) | ||
}) | ||
|
||
|
@@ -193,7 +222,7 @@ Last updated {{.LastUpdated}} | |
source := `= Document Title | ||
a paragraph` | ||
expected := `<!DOCTYPE html> | ||
expectedTmpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
@@ -213,7 +242,7 @@ a paragraph` | |
</div> | ||
<div id="footer"> | ||
<div id="footer-text"> | ||
Last updated {{.LastUpdated}} | ||
Last updated {{ .LastUpdated }} | ||
</div> | ||
</div> | ||
</body> | ||
|
@@ -223,14 +252,19 @@ Last updated {{.LastUpdated}} | |
configuration.WithHeaderFooter(true), | ||
configuration.WithLastUpdated(now), | ||
configuration.WithAttributes(map[string]interface{}{}), | ||
)).To(MatchHTMLTemplate(expected, now)) | ||
)).To(MatchHTMLTemplate(expectedTmpl, | ||
struct { | ||
LastUpdated string | ||
}{ | ||
LastUpdated: now.Format(configuration.LastUpdatedFormat), | ||
})) | ||
}) | ||
|
||
It("with header and without footer", func() { | ||
source := `= Document Title | ||
a paragraph` | ||
expected := `<!DOCTYPE html> | ||
expectedTmpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
@@ -257,14 +291,19 @@ a paragraph` | |
configuration.WithAttributes(map[string]interface{}{ | ||
types.AttrNoFooter: "", | ||
}), | ||
)).To(MatchHTMLTemplate(expected, now)) | ||
)).To(MatchHTMLTemplate(expectedTmpl, | ||
struct { | ||
LastUpdated string | ||
}{ | ||
LastUpdated: now.Format(configuration.LastUpdatedFormat), | ||
})) | ||
}) | ||
|
||
It("without header and with footer", func() { | ||
source := `= Document Title | ||
a paragraph` | ||
expected := `<!DOCTYPE html> | ||
expectedTmpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
@@ -281,7 +320,7 @@ a paragraph` | |
</div> | ||
<div id="footer"> | ||
<div id="footer-text"> | ||
Last updated {{.LastUpdated}} | ||
Last updated {{ .LastUpdated }} | ||
</div> | ||
</div> | ||
</body> | ||
|
@@ -293,14 +332,19 @@ Last updated {{.LastUpdated}} | |
configuration.WithAttributes(map[string]interface{}{ | ||
types.AttrNoHeader: "", | ||
}), | ||
)).To(MatchHTMLTemplate(expected, now)) | ||
)).To(MatchHTMLTemplate(expectedTmpl, | ||
struct { | ||
LastUpdated string | ||
}{ | ||
LastUpdated: now.Format(configuration.LastUpdatedFormat), | ||
})) | ||
}) | ||
|
||
It("without header and without footer", func() { | ||
source := `= Document Title | ||
a paragraph` | ||
expected := `<!DOCTYPE html> | ||
expectedTmpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
@@ -325,7 +369,12 @@ a paragraph` | |
types.AttrNoHeader: "", | ||
types.AttrNoFooter: "", | ||
}), | ||
)).To(MatchHTMLTemplate(expected, now)) | ||
)).To(MatchHTMLTemplate(expectedTmpl, | ||
struct { | ||
LastUpdated string | ||
}{ | ||
LastUpdated: now.Format(configuration.LastUpdatedFormat), | ||
})) | ||
}) | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.