From e48975f974a13e140b5a366c09f5695c2d1d76ee Mon Sep 17 00:00:00 2001 From: Unmesh Gundecha Date: Sun, 21 Feb 2021 15:41:32 +0800 Subject: [PATCH] Refactor tests --- test/main.spec.js | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/test/main.spec.js b/test/main.spec.js index cca4099..692593d 100644 --- a/test/main.spec.js +++ b/test/main.spec.js @@ -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>)/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>)/g); + expect(orgList).to.be.sorted(Intl.Collator().compare); }); }); \ No newline at end of file