Skip to content

Commit

Permalink
test(parser/renderer): custom table borders (#1026)
Browse files Browse the repository at this point in the history
verifies that the 'frame' and 'grid' attributes are supported

Fixes #1016

Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
  • Loading branch information
xcoulon authored May 17, 2022
1 parent c680ac4 commit 2c0586b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pkg/parser/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ var _ = Describe("tables", func() {

Context("in final documents", func() {

It("1-line table with 2 cells", func() {
source := `|===
It("1-line table with 2 cells and custom border styling", func() {
source := `[frame=ends,grid=rows]
|===
| *cookie* cookie | _pasta_
|===
`
expected := &types.Document{
Elements: []interface{}{
&types.Table{
Attributes: types.Attributes{
types.AttrFrame: "ends",
types.AttrGrid: "rows",
},
Rows: []*types.TableRow{
{
Cells: []*types.TableCell{
Expand Down
23 changes: 22 additions & 1 deletion pkg/renderer/sgml/html5/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

var _ = Describe("tables", func() {

It("1-line table with 2 cells", func() {
It("1-line table with 2 cells and default border styling", func() {
source := `|===
| *foo* foo | _bar_
|===`
Expand All @@ -29,6 +29,27 @@ var _ = Describe("tables", func() {
Expect(RenderHTML(source)).To(MatchHTML(expected))
})

It("1-line table with 2 cells and custom border styling", func() {
source := `[frame=ends,grid=rows]
|===
| *foo* foo | _bar_
|===`
expected := `<table class="tableblock frame-ends grid-rows stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>foo</strong> foo</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>bar</em></p></td>
</tr>
</tbody>
</table>
`
Expect(RenderHTML(source)).To(MatchHTML(expected))
})

It("1-line table with 3 cells", func() {
source := `|===
| *foo* foo | _bar_ | baz
Expand Down

0 comments on commit 2c0586b

Please sign in to comment.