2020-05-01 16:03:48 +00:00
|
|
|
import { readFile, readdir } from 'fs-extra';
|
2020-02-18 07:34:10 +00:00
|
|
|
|
|
|
|
describe('versioning metadata', () => {
|
|
|
|
it('readme no markdown headers', async () => {
|
|
|
|
const allVersioning = (await readdir('lib/versioning')).filter(
|
2020-04-12 16:09:36 +00:00
|
|
|
(item) => !item.includes('.')
|
2020-02-18 07:34:10 +00:00
|
|
|
);
|
|
|
|
for (const versioning of allVersioning) {
|
|
|
|
let readme: string;
|
|
|
|
try {
|
|
|
|
readme = await readFile(
|
|
|
|
'lib/versioning/' + versioning + '/readme.md',
|
|
|
|
'utf8'
|
|
|
|
);
|
|
|
|
} catch (err) {
|
|
|
|
// ignore missing file
|
|
|
|
}
|
|
|
|
if (readme) {
|
2020-09-07 07:54:07 +00:00
|
|
|
// eslint-disable-next-line jest/no-conditional-expect
|
2020-05-18 12:33:44 +00:00
|
|
|
expect(RegExp(/(^|\n)#+ /).exec(readme)).toBeNull();
|
2020-02-18 07:34:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
it('contains mandatory fields', async () => {
|
|
|
|
const allVersioning = (await readdir('lib/versioning')).filter(
|
2020-04-12 16:09:36 +00:00
|
|
|
(item) => !item.includes('.') && !item.startsWith('_')
|
2020-02-18 07:34:10 +00:00
|
|
|
);
|
2020-03-05 20:57:24 +00:00
|
|
|
|
2020-02-18 07:34:10 +00:00
|
|
|
for (const versioning of allVersioning) {
|
2020-03-05 20:57:24 +00:00
|
|
|
const versioningObj = require(`./${versioning}`);
|
2020-02-18 07:34:10 +00:00
|
|
|
expect(versioningObj.id).toEqual(versioning);
|
|
|
|
expect(versioningObj.displayName).toBeDefined();
|
|
|
|
expect(versioningObj.urls).toBeDefined();
|
|
|
|
expect(versioningObj.supportsRanges).toBeDefined();
|
|
|
|
if (versioningObj.supportsRanges === true) {
|
2020-09-07 07:54:07 +00:00
|
|
|
// eslint-disable-next-line jest/no-conditional-expect
|
2020-02-18 07:34:10 +00:00
|
|
|
expect(versioningObj.supportedRangeStrategies).toBeDefined();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|