extract.test.js 905 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const assert = require('assert');
  2. const extract = require('../tools/extract');
  3. const md = `# The Title
  4. ## Subsection 1 - Ain't it cool
  5. Content for subsection 1 with \`markdown\` stuff.
  6. Another paragraph.
  7. ## Subsection 2 - Wow it works!
  8. Content for subsection 2.`
  9. describe('extract', () => {
  10. it('build the correct structure', () => {
  11. const actual = extract(md);
  12. const expected = {
  13. title: 'The Title',
  14. path: '/the-title',
  15. items: [
  16. {
  17. title: 'Subsection 1 - Ain\'t it cool',
  18. path: '/subsection-1-aint-it-cool',
  19. content: 'Content for subsection 1 with `markdown` stuff.\n\nAnother paragraph.'
  20. },
  21. {
  22. title: 'Subsection 2 - Wow it works!',
  23. path: '/subsection-2-wow-it-works',
  24. content: 'Content for subsection 2.'
  25. }
  26. ]
  27. };
  28. assert.deepStrictEqual(actual, expected);
  29. });
  30. });