@@ -126,22 +126,66 @@ defmodule ExDoc.Formatter.EPUBTest do
126126 assert content =~ ~r{ .*"Mix\. Tasks\. TaskWithDocs\" .*} ms
127127 end
128128
129- test "generates the readme file" , % { tmp_dir: tmp_dir } = context do
129+ test "generates the readme file as main " , % { tmp_dir: tmp_dir } = context do
130130 config = doc_config ( context , main: "README" , extras: [ "test/fixtures/README.md" ] )
131131 generate_docs_and_unzip ( context , config )
132132
133- content = File . read! ( tmp_dir <> "/epub/OEBPS/readme.xhtml" )
134- assert content =~ ~r{ <title>README [^<]*</title>}
135- assert content =~ ~r{ <a href="RandomError.xhtml"><code(\s class="inline")?>RandomError</code>}
133+ content = File . read! ( tmp_dir <> "/epub/OEBPS/nav.xhtml" )
134+ assert content =~ ~r{ <li><a href="readme.xhtml">README</a></li>}
135+ end
136+
137+ test "generates extras" , % { tmp_dir: tmp_dir } = context do
138+ config =
139+ doc_config ( context ,
140+ extras: [
141+ "test/fixtures/LICENSE" ,
142+ "test/fixtures/PlainText.txt" ,
143+ "test/fixtures/PlainTextFiles.md" ,
144+ "test/fixtures/README.md" ,
145+ "test/fixtures/LivebookFile.livemd" ,
146+ "test/fixtures/cheatsheets.cheatmd"
147+ ]
148+ )
149+
150+ generate_docs_and_unzip ( context , config )
151+
152+ content = File . read! ( tmp_dir <> "/epub/OEBPS/plaintextfiles.xhtml" )
153+
154+ assert content =~ ~r{ Plain Text Files</h1>} s
136155
137156 assert content =~
138- ~r{ <a href="CustomBehaviourImpl.xhtml#hello/1"><code(\s class="inline")?>CustomBehaviourImpl.hello/1</code>}
157+ ~r{ <p>Read the <a href="license.xhtml">license</a> and the <a href="plaintext.xhtml">plain-text file</a>.}
158+
159+ plain_text_file = File . read! ( tmp_dir <> "/epub/OEBPS/plaintext.xhtml" )
160+
161+ assert plain_text_file =~ ~r{ PlainText</h1>} s
162+
163+ assert plain_text_file =~
164+ ~r{ <pre>\n This is plain\n text and nothing\n .+\s +good bye\n </pre>} s
165+
166+ assert plain_text_file =~ ~s{ \n ## Neither formatted\n }
167+ assert plain_text_file =~ ~s{ \n `t:term/0`\n }
168+
169+ license = File . read! ( tmp_dir <> "/epub/OEBPS/license.xhtml" )
170+
171+ assert license =~ ~r{ LICENSE</h1>} s
172+
173+ assert license =~
174+ ~s{ <pre>\n Licensed under the Apache License, Version 2.0 (the "License")}
175+
176+ content = File . read! ( tmp_dir <> "/epub/OEBPS/livebookfile.xhtml" )
177+
178+ assert content =~ ~r{ Title for Livebook Files</h1>}
139179
140180 assert content =~
141- ~r { <a href="TypesAndSpecs.Sub.xhtml"> <code( \s class ="inline")?>TypesAndSpecs.Sub </code></a> }
181+ ~s { <p>Read <code class ="inline">.livemd </code> files generated by <a href="https://github.com/livebook-dev/livebook">livebook</a>. }
142182
143- content = File . read! ( tmp_dir <> "/epub/OEBPS/nav.xhtml" )
144- assert content =~ ~r{ <li><a href="readme.xhtml">README</a></li>}
183+ content = File . read! ( tmp_dir <> "/epub/OEBPS/cheatsheets.xhtml" )
184+
185+ assert content =~ ~s{ <h2 id="getting-started">}
186+ assert content =~ ~s{ <h3 id="hello-world">}
187+ assert content =~ ~s{ <h2 id="types">}
188+ assert content =~ ~s{ <h3 id="operators">}
145189 end
146190
147191 test "ignores any external url extras" , % { tmp_dir: tmp_dir } = context do
0 commit comments