Skip to content

Commit

Permalink
Test Liquid whitespace control (github#35651)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Mar 17, 2023
1 parent 9ffd1e3 commit 9f5cae3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
1 change: 1 addition & 0 deletions tests/fixtures/content/get-started/liquid/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ children:
- /tips
- /notes
- /platform-specific
- /whitespace
- /table-row-headers
---
30 changes: 30 additions & 0 deletions tests/fixtures/content/get-started/liquid/whitespace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Whitespace
intro: Demonstrates use of `-` in Liquid tags
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
type: how_to
---

## Paragraphs

Text above.

{% data variables.product.product_name %}

Test below.

## Paragraph

Text before. {% data variables.product.product_name %} Text after.

Cram{% ifversion fpt %}FPT{% endif %}ped.

## List

- One
- {% data variables.product.product_name %}
- Three
19 changes: 19 additions & 0 deletions tests/rendering-fixtures/liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ describe('extended Markdown', () => {
expect($('h2#in-this-article + nav ul div.extended-markdown.linux').length).toBe(1)
})

test('whitespace control', async () => {
const $ = await getDOM('/get-started/liquid/whitespace')
const html = $('#article-contents').html()
expect(html).toMatch('<p>GitHub</p>')
expect(html).toMatch('<p>Text before. GitHub Text after.</p>')
expect(html).toMatch('<li>GitHub</li>')
expect(html).toMatch('CramFPTped')

// Test what happens to `Cram{% ifversion fpt %}FPT{% endif %}ped.`
// when it's not free-pro-team.
{
const $ = await getDOM('/enterprise-server@latest/get-started/liquid/whitespace')
const html = $('#article-contents').html()
// Assures that there's not whitespace left when the `{% ifversion %}`
// yields an empty string.
expect(html).toMatch('Cramped')
}
})

test('rowheaders', async () => {
const $ = await getDOM('/get-started/liquid/table-row-headers')
const tables = $('#article-contents table')
Expand Down
8 changes: 0 additions & 8 deletions tests/rendering/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,6 @@ describe('server', () => {
).toBe(true)
})

test('handles whitespace control in liquid tags', async () => {
// example from markdown source of index:
// Liquid tags with {%- in lists should not result in newlines
// that convert to <p>s in <li>s
const $ = await getDOM('/')
expect($('li > p').length).toBe(0)
})

test('renders liquid within liquid within liquid', async () => {
const $ = await getDOM('/en/articles/enabling-required-status-checks')
expect($('ol li').first().text().trim()).toBe(
Expand Down

0 comments on commit 9f5cae3

Please sign in to comment.