Added sort test and switch to chai expect

This commit is contained in:
Unmesh Gundecha
2021-02-21 13:54:08 +08:00
parent 0c8c1c8253
commit eaf9286b67
4 changed files with 89 additions and 59 deletions

View File

@@ -1,18 +1,36 @@
const fs = require('fs');
const { assert } = require('chai');
const chai = require('chai');
chai.use(require('chai-arrays'));
chai.use(require('chai-string'));
var expect = chai.expect;
const srcMd = fs.readFileSync('README.md', 'utf8');
describe('Header', function() {
it('Starts with #', function() {
assert.isOk(srcMd.startsWith('# How they SRE'), 'Header is broken');
expect(srcMd).to. startsWith('# How they SRE');
});
});
describe('Sections', function() {
['Introduction', 'Organizations', 'Resources', 'Credits', 'Other How They... repos', 'Contribute', 'License'] .forEach(function (section) {
['Introduction',
'Organizations',
'Resources',
'Credits',
'Other How They... repos',
'Contribute',
'License'].forEach(function (section) {
it(`${section}`, function() {
assert.isOk(srcMd.includes(`## ${section}`), `${section} section is missing`);
expect(srcMd).to.contain(`## ${section}`);
});
});
});
describe('Order', function() {
it('Organization list is sorted', function() {
var list = srcMd.match(/(?<=<summary>)(.*?)(?=<\/summary>)/g);
expect(list).to.be.sorted(Intl.Collator().compare);
});
});