Merge remote-tracking branch 'upstream/main' into default-platform
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
const fs = require('fs').promises
|
||||
const path = require('path')
|
||||
|
||||
const { GITHUB_ACTIONS, GITHUB_REPOSITORY } = process.env
|
||||
const runningActionsOnInternalRepo = GITHUB_ACTIONS === 'true' && GITHUB_REPOSITORY === 'github/docs-internal'
|
||||
const testViaActionsOnly = runningActionsOnInternalRepo ? test : test.skip
|
||||
const { testViaActionsOnly } = require('../helpers/conditional-runs')
|
||||
|
||||
describe('cloning early-access', () => {
|
||||
testViaActionsOnly('the content directory exists', async () => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const { liquid } = require('../../lib/render-content')
|
||||
const { loadPageMap } = require('../../lib/pages')
|
||||
const entities = new (require('html-entities').XmlEntities)()
|
||||
const { set } = require('lodash')
|
||||
const nonEnterpriseDefaultVersion = require('../../lib/non-enterprise-default-version')
|
||||
|
||||
describe('liquid helper tags', () => {
|
||||
@@ -15,11 +14,16 @@ describe('liquid helper tags', () => {
|
||||
context.currentVersion = nonEnterpriseDefaultVersion
|
||||
context.pages = pageMap
|
||||
context.redirects = []
|
||||
context.site = {}
|
||||
context.site = {
|
||||
data: {
|
||||
reusables: {
|
||||
example: 'a rose by any other name\nwould smell as sweet'
|
||||
}
|
||||
}
|
||||
}
|
||||
context.page = {
|
||||
relativePath: 'desktop/index.md'
|
||||
}
|
||||
set(context.site, 'data.reusables.example', 'a rose by any other name\nwould smell as sweet')
|
||||
done()
|
||||
})
|
||||
|
||||
@@ -83,8 +87,6 @@ describe('liquid helper tags', () => {
|
||||
})
|
||||
|
||||
describe('indented_data_reference tag', () => {
|
||||
set(context.site, 'data.reusables.example', 'a rose by any other name\nwould smell as sweet')
|
||||
|
||||
test('without any number of spaces specified', async () => {
|
||||
const template = '{% indented_data_reference site.data.reusables.example %}'
|
||||
const expected = ` a rose by any other name
|
||||
@@ -117,4 +119,47 @@ would smell as sweet`
|
||||
expect(output).toBe(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe('data tag', () => {
|
||||
test(
|
||||
'handles bracketed array access within for-in loop',
|
||||
async () => {
|
||||
const template = `
|
||||
{% for term in site.data.glossaries.external %}
|
||||
### {% data glossaries.external[forloop.index0].term %}
|
||||
{% data glossaries.external[forloop.index0].description %}
|
||||
---
|
||||
{% endfor %}`
|
||||
|
||||
const localContext = { ...context }
|
||||
localContext.site = {
|
||||
data: {
|
||||
variables: {
|
||||
fire_emoji: ':fire:'
|
||||
},
|
||||
glossaries: {
|
||||
external: [
|
||||
{ term: 'lit', description: 'Awesome things. {% data variables.fire_emoji %}' },
|
||||
{ term: 'Zhu Li', description: '_"Zhu Li, do the thing!"_ :point_up:' }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const expected = `
|
||||
|
||||
### lit
|
||||
Awesome things. :fire:
|
||||
---
|
||||
|
||||
### Zhu Li
|
||||
_"Zhu Li, do the thing!"_ :point_up:
|
||||
---
|
||||
`
|
||||
|
||||
const output = await liquid.parseAndRender(template, localContext)
|
||||
expect(output).toBe(expected)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user