blob: 3f74df5c5c30f2c0663a83dfa11ca8c9b4fd07a9 [file] [log] [blame]
import fs from 'fs';
function extractFirstCapturingGroup(
body: string,
pattern: RegExp,
): never | string {
const m = pattern.exec(body);
if (m === null) {
throw new Error('No match found');
}
return m[1];
}
describe('README.md', (): void => {
it('inputs section on README.md should have the same content as action.yml', (): void => {
const contentReadme = fs.readFileSync('README.md', 'utf-8');
const contentActionYml = fs.readFileSync('action.yml', 'utf-8');
const inputsReadme = extractFirstCapturingGroup(
contentReadme,
/## Inputs\s+```yml(.+?)```/s,
).trim();
const inputsActionYml = extractFirstCapturingGroup(
contentActionYml,
/(inputs.+?)\s+runs/s,
).trim();
expect(inputsReadme).toBe(inputsActionYml);
});
});