2021-12-22 11:28:20 +00:00
|
|
|
import fs from 'fs-extra';
|
2020-02-29 21:55:36 +00:00
|
|
|
|
2022-03-03 09:35:26 +00:00
|
|
|
describe('modules/manager/metadata', () => {
|
2020-02-29 21:55:36 +00:00
|
|
|
const managerList: string[] = fs
|
|
|
|
.readdirSync(__dirname, { withFileTypes: true })
|
2020-04-12 16:09:36 +00:00
|
|
|
.filter((dirent) => dirent.isDirectory())
|
|
|
|
.map((dirent) => dirent.name)
|
|
|
|
.filter((name) => !name.startsWith('__'))
|
2020-02-29 21:55:36 +00:00
|
|
|
.sort();
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2020-04-12 16:09:36 +00:00
|
|
|
test.each(managerList)('%s has readme with no h1 or h2', async (manager) => {
|
2022-06-20 15:05:39 +00:00
|
|
|
let readme: string | undefined;
|
2020-02-29 21:55:36 +00:00
|
|
|
try {
|
|
|
|
readme = await fs.readFile(`${__dirname}/${manager}/readme.md`, 'utf8');
|
|
|
|
} catch (err) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
expect(readme).toBeDefined();
|
2022-06-20 15:05:39 +00:00
|
|
|
const lines = readme!.split('\n');
|
2020-03-23 13:06:20 +00:00
|
|
|
let isCode = false;
|
|
|
|
const res: string[] = [];
|
|
|
|
|
|
|
|
for (const line of lines) {
|
|
|
|
if (line.startsWith('```')) {
|
|
|
|
isCode = !isCode;
|
|
|
|
} else if (!isCode) {
|
|
|
|
res.push(line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-29 21:55:36 +00:00
|
|
|
expect(
|
2020-04-12 16:09:36 +00:00
|
|
|
res.some((line) => line.startsWith('# ') || line.startsWith('## '))
|
2021-10-27 05:24:36 +00:00
|
|
|
).toBeFalse();
|
2020-02-29 21:55:36 +00:00
|
|
|
});
|
|
|
|
});
|