Refactor tests

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

View File

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