Refactor tests

This commit is contained in:
Unmesh Gundecha
2021-02-21 15:41:32 +08:00
parent 76db0a6c35
commit e48975f974

View File

@@ -8,29 +8,32 @@ var expect = chai.expect;
const srcMd = fs.readFileSync('README.md', 'utf8');
describe('Header', function() {
it('Starts with #', function() {
expect(srcMd).to. startsWith('# How they SRE');
});
});
describe('Sections', function() {
['Introduction',
'Organizations',
'Resources',
'Credits',
'Other How They... repos',
'Contribute',
'License'].forEach(function (section) {
it(`${section}`, function() {
expect(srcMd).to.contain(`## ${section}`);
});
describe('Header', function () {
it('is intact', function () {
expect(srcMd).to.startsWith('# How they SRE');
});
});
describe('Order', function() {
it('Organization list is sorted', function() {
var list = srcMd.match(/(?<=<summary>)(.*?)(?=<\/summary>)/g);
expect(list).to.be.sorted(Intl.Collator().compare);
describe('Section Headers', function () {
it('intact', function () {
var expectedH2List = [
'## Introduction',
'## Organizations',
'## SRECon Mix Playlist',
'## Resources',
'## Credits',
'## Other How They... repos',
'## Contribute',
'## License'
]
var actualList = srcMd.match(/^## (.*$)/gim);
expect(expectedH2List).to.equalTo(actualList)
});
});
describe('Organization list', function () {
it('is sorted', function () {
var orgList = srcMd.match(/(?<=<summary>)(.*?)(?=<\/summary>)/g);
expect(orgList).to.be.sorted(Intl.Collator().compare);
});
});