1defmodule Acceptance.FootnotesTest do
2  use ExUnit.Case
3
4  import Support.Helpers, only: [ as_html: 2]
5
6  # describe "Footnotes" do
7
8    test "without errors" do
9      markdown = "foo[^1] again\n\n[^1]: bar baz"
10      html     = ~s{<p>foo<a href="#fn:1" id="fnref:1" class="footnote" title="see footnote">1</a> again</p>\n<div class="footnotes">\n<hr>\n<ol>\n<li id="fn:1"><p>bar baz&nbsp;<a href="#fnref:1" title="return to article" class="reversefootnote">&#x21A9;</a></p>\n</li>\n</ol>\n\n</div>}
11      messages = []
12
13      assert as_html(markdown, footnotes: true) == {:ok, html, messages}
14    end
15
16    test "undefined footnotes" do
17      markdown = "foo[^1]\nhello\n\n[^2]: bar baz"
18      html     = ~s{<p>foo[^1]\nhello</p>\n}
19      messages = [{:error, 1, "footnote 1 undefined, reference to it ignored"}]
20
21      assert as_html(markdown, footnotes: true) == {:error, html, messages}
22    end
23
24    test "undefined footnotes (none at all)" do
25      markdown = "foo[^1]\nhello"
26      html     = ~s{<p>foo[^1]\nhello</p>\n}
27      messages = [{:error, 1, "footnote 1 undefined, reference to it ignored"}]
28
29      assert as_html(markdown, footnotes: true) == {:error, html, messages}
30    end
31
32    test "illdefined footnotes" do
33      markdown = "foo[^1]\nhello\n\n[^1]:bar baz"
34      html     = ~s{<p>foo[^1]\nhello</p>\n<p>[^1]:bar baz</p>\n}
35      messages = [
36        {:error, 1, "footnote 1 undefined, reference to it ignored"},
37        {:error, 4, "footnote 1 undefined, reference to it ignored"}]
38
39      assert as_html(markdown, footnotes: true) == {:error, html, messages}
40    end
41
42
43  # end
44
45end
46
47# SPDX-License-Identifier: Apache-2.0
48