| | import yaml from 'js-yaml' |
| | import { readFile } from 'fs/promises' |
| |
|
| | import walk from 'walk-sync' |
| | import { beforeAll, describe, expect, test } from 'vitest' |
| |
|
| | import { liquid } from '@/content-render/index' |
| |
|
| | const learningTrackRootPath = 'data/learning-tracks' |
| | const yamlWalkOptions = { |
| | globs: ['**/*.yml'], |
| | directories: false, |
| | includeBasePath: true, |
| | } |
| | const yamlFileList = walk(learningTrackRootPath, yamlWalkOptions).sort() |
| |
|
| | describe('lint learning tracks', () => { |
| | if (yamlFileList.length < 1) return |
| |
|
| | describe.each(yamlFileList)('%s', (yamlAbsPath) => { |
| | |
| | let yamlContent: any |
| |
|
| | beforeAll(async () => { |
| | const fileContents = await readFile(yamlAbsPath, 'utf8') |
| | yamlContent = await yaml.load(fileContents) |
| | }) |
| |
|
| | test('contains valid liquid', () => { |
| | |
| | const toLint: any[] = [] |
| | |
| | for (const { title, description } of Object.values(yamlContent) as any[]) { |
| | toLint.push(title) |
| | toLint.push(description) |
| | } |
| |
|
| | for (const element of toLint) { |
| | expect(() => liquid.parse(element), `${element} contains invalid liquid`).not.toThrow() |
| | } |
| | }) |
| | }) |
| | }) |
| |
|