const assert = require('assert');
const extract = require('../tools/extract');

const md = `# The Title

## Subsection 1 - Ain't it cool

Content for subsection 1 with \`markdown\` stuff.

Another paragraph.

## Subsection 2 - Wow it works!

Content for subsection 2.`

describe('extract', () => {
  it('build the correct structure', () => {
    const actual = extract(md);
    const expected = {
      title: 'The Title',
      path: '/the-title',
      items: [
        {
          title: 'Subsection 1 - Ain\'t it cool',
          path: '/subsection-1-aint-it-cool',
          content: 'Content for subsection 1 with `markdown` stuff.\n\nAnother paragraph.'
        },
        {
          title: 'Subsection 2 - Wow it works!',
          path: '/subsection-2-wow-it-works',
          content: 'Content for subsection 2.'
        }
      ]
    };
    assert.deepStrictEqual(actual, expected);
  });
});
