-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Write test for bad pattern: .md/# (#23609)
- Loading branch information
1 parent
6001f97
commit 8aad74f
Showing
5 changed files
with
91 additions
and
123 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import fs from 'fs-extra'; | ||
import { glob } from 'glob'; | ||
import { getOptions } from '../lib/config/options'; | ||
import { regEx } from '../lib/util/regex'; | ||
|
||
const options = getOptions(); | ||
const markdownGlob = '{docs,lib}/**/*.md'; | ||
|
||
describe('documentation', () => { | ||
it('has no invalid links', async () => { | ||
const markdownFiles = await glob(markdownGlob); | ||
|
||
await Promise.all( | ||
markdownFiles.map(async (markdownFile) => { | ||
const markdownText = await fs.readFile(markdownFile, 'utf8'); | ||
expect(markdownText).not.toMatch(regEx(/\.md\/#/)); | ||
}) | ||
); | ||
}); | ||
|
||
describe('website-documentation', () => { | ||
describe('configuration-options', () => { | ||
const doc = fs.readFileSync( | ||
'docs/usage/configuration-options.md', | ||
'utf8' | ||
); | ||
|
||
const headers = doc | ||
.match(/\n## (.*?)\n/g) | ||
?.map((match) => match.substring(4, match.length - 1)); | ||
|
||
const expectedOptions = options | ||
.filter((option) => !option.globalOnly) | ||
.filter((option) => !option.parent) | ||
.filter((option) => !option.autogenerated) | ||
.map((option) => option.name) | ||
.sort(); | ||
|
||
it('has doc headers sorted alphabetically', () => { | ||
expect(headers).toEqual([...headers!].sort()); | ||
}); | ||
|
||
it('has headers for every required option', () => { | ||
expect(headers).toEqual(expectedOptions); | ||
}); | ||
|
||
const subHeaders = doc | ||
.match(/\n### (.*?)\n/g) | ||
?.map((match) => match.substring(5, match.length - 1)); | ||
subHeaders!.sort(); | ||
const expectedSubOptions = options | ||
.filter((option) => option.stage !== 'global') | ||
.filter((option) => !option.globalOnly) | ||
.filter((option) => option.parent) | ||
.map((option) => option.name) | ||
.sort(); | ||
expectedSubOptions.sort(); | ||
|
||
it('has headers for every required sub-option', () => { | ||
expect(subHeaders).toEqual(expectedSubOptions); | ||
}); | ||
}); | ||
|
||
describe('self-hosted-configuration', () => { | ||
const doc = fs.readFileSync( | ||
'docs/usage/self-hosted-configuration.md', | ||
'utf8' | ||
); | ||
|
||
const headers = doc | ||
.match(/\n## (.*?)\n/g) | ||
?.map((match) => match.substring(4, match.length - 1)); | ||
|
||
const expectedOptions = options | ||
.filter((option) => !!option.globalOnly) | ||
.map((option) => option.name) | ||
.sort(); | ||
|
||
it('has headers sorted alphabetically', () => { | ||
expect(headers).toEqual([...headers!].sort()); | ||
}); | ||
|
||
it('has headers for every required option', () => { | ||
expect(headers).toEqual(expectedOptions); | ||
}); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.