From 9df5a8b8aacd8f194fb17818954bb8e73189da72 Mon Sep 17 00:00:00 2001 From: streamich Date: Fri, 1 Mar 2019 17:49:44 +0100 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20test=20footnote=20orderi?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/md/footnote-order.md | 7 +++++++ src/__tests__/mdastToFlat.spec.ts | 11 +++++++++++ src/__tests__/replace.spec.ts | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/__tests__/md/footnote-order.md diff --git a/src/__tests__/md/footnote-order.md b/src/__tests__/md/footnote-order.md new file mode 100644 index 00000000..be7726a8 --- /dev/null +++ b/src/__tests__/md/footnote-order.md @@ -0,0 +1,7 @@ +[^b]: Footnote b + +Hello [^a][^b][^c] + +[^c]: Footnote c + +[^a]: Footnote a diff --git a/src/__tests__/mdastToFlat.spec.ts b/src/__tests__/mdastToFlat.spec.ts index cd497922..41e3f501 100644 --- a/src/__tests__/mdastToFlat.spec.ts +++ b/src/__tests__/mdastToFlat.spec.ts @@ -404,4 +404,15 @@ describe('structure', () => { footnoteOrder: [10, 19], }); }); + + it('footnotes are ordered', () => { + const parser = create(); + const md = fs.readFileSync(__dirname + '/md/footnote-order.md', 'utf8'); + const mdast = parser.tokenizeBlock(md)!; + const flat = mdastToFlat(mdast); + + expect(flat.footnotes.a).toBe(flat.footnoteOrder[0]); + expect(flat.footnotes.b).toBe(flat.footnoteOrder[1]); + expect(flat.footnotes.c).toBe(flat.footnoteOrder[2]); + }); }); diff --git a/src/__tests__/replace.spec.ts b/src/__tests__/replace.spec.ts index a3fef92d..dd8d9903 100644 --- a/src/__tests__/replace.spec.ts +++ b/src/__tests__/replace.spec.ts @@ -63,7 +63,7 @@ describe('structure', () => { }); }); - it.only('merges metadata', () => { + it('merges metadata', () => { const parser = create(); const mdast1 = parser.tokenizeBlock(` # Click [here][link1] world! [^foot]