Skip to content

Commit 0d7e3da

Browse files
Update tests for bake_folio
1 parent b1c33d0 commit 0d7e3da

3 files changed

+187
-0
lines changed

spec/kitchen_spec/directions/bake_folio_spec.rb

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,55 @@
5858
)
5959
end
6060

61+
let(:book_with_folio_and_units) do
62+
book_containing(html:
63+
<<~HTML
64+
<div data-type="unit">
65+
<div data-type="chapter">
66+
<h1 data-type="document-title">
67+
<span class="os-text">Chapter title</span>
68+
</h1>
69+
<div data-type="page" class="introduction">
70+
<h2 data-type="document-title">
71+
<span class="os-text">Introduction title</span>
72+
</h2>
73+
</div>
74+
<div data-type="page">
75+
<h2 data-type="document-title">
76+
<span class="os-text">Module title</span>
77+
</h2>
78+
</div>
79+
<div data-type="composite-page" class="os-eoc">
80+
<h2 data-type="document-title">
81+
<span class="os-text">Eoc title</span>
82+
</h2>
83+
</div>
84+
</div>
85+
</div>
86+
<div data-type="page" class="appendix">
87+
<h1 data-type="document-title">
88+
<span class="os-text">Appendix title</span>
89+
</h1>
90+
</div>
91+
<div data-type="composite-chapter" class="os-eob os-solutions-container">
92+
<h1 data-type="document-title">
93+
<span class="os-text">Answer Key title</span>
94+
</h1>
95+
<div data-type="composite-page" class="os-eob os-solutions-container">
96+
<h2 data-type="document-title">
97+
<span class="os-text">Chapter title</span>
98+
</h2>
99+
</div>
100+
</div>
101+
<div data-type="composite-page" class="os-eob">
102+
<h1 data-type="document-title">
103+
<span class="os-text">Index title</span>
104+
</h1>
105+
</div>
106+
HTML
107+
)
108+
end
109+
61110
describe 'folio pdf translations' do
62111
it 'works in english' do
63112
described_class.v1(book: book)
@@ -77,6 +126,22 @@
77126
described_class.v1(book: book_with_folio, options: { new_approach: true })
78127
expect(book_with_folio).to match_snapshot_auto
79128
end
129+
130+
it 'works with units when unit numbering disabled' do
131+
described_class.v1(
132+
book: book_with_folio_and_units,
133+
chapters: book_with_folio_and_units.units.chapters,
134+
options: { new_approach: true, numbering_options: { mode: :chapter_page } })
135+
expect(book_with_folio_and_units).to match_snapshot_auto
136+
end
137+
138+
it 'works with units when unit numbering enabled' do
139+
described_class.v1(
140+
book: book_with_folio_and_units,
141+
chapters: book_with_folio_and_units.units.chapters,
142+
options: { new_approach: true, numbering_options: { mode: :unit_chapter_page } })
143+
expect(book_with_folio_and_units).to match_snapshot_auto
144+
end
80145
end
81146
end
82147
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<html xmlns:m="http://www.w3.org/1998/Math/MathML" data-pdf-folio-preface-message="Preface" data-pdf-folio-access-message="Access for free at openstax.org">
2+
<body>
3+
<div data-type="unit">
4+
<div data-type="chapter">
5+
<h1 data-type="document-title">
6+
<span class="os-text">Chapter title</span>
7+
</h1><p class="folio-chapter">
8+
1 &#x2022; Chapter title
9+
</p>
10+
<div data-type="page" class="introduction">
11+
<h2 data-type="document-title">
12+
<span class="os-text">Introduction title</span>
13+
</h2><p class="folio-module">
14+
1 &#x2022; Introduction title
15+
</p>
16+
</div>
17+
<div data-type="page">
18+
<h2 data-type="document-title">
19+
<span class="os-text">Module title</span>
20+
</h2><p class="folio-module">
21+
1.1 &#x2022; Module title
22+
</p>
23+
</div>
24+
<div data-type="composite-page" class="os-eoc">
25+
<h2 data-type="document-title">
26+
<span class="os-text">Eoc title</span>
27+
</h2><p class="folio-eoc-right">
28+
1 &#x2022; Eoc title
29+
</p><p class="folio-eoc-left">
30+
1 &#x2022; Eoc title
31+
</p>
32+
</div>
33+
</div>
34+
</div>
35+
<div data-type="page" class="appendix">
36+
<h1 data-type="document-title">
37+
<span class="os-text">Appendix title</span>
38+
</h1><p class="folio-appendix-right">
39+
A &#x2022; Appendix title
40+
</p><p class="folio-appendix-left">
41+
A &#x2022; Appendix title
42+
</p>
43+
</div>
44+
<div data-type="composite-chapter" class="os-eob os-solutions-container">
45+
<h1 data-type="document-title">
46+
<span class="os-text">Answer Key title</span>
47+
</h1><p class="folio-eob-right">Answer Key title</p><p class="folio-eob-left">Answer Key title</p>
48+
<div data-type="composite-page" class="os-eob os-solutions-container">
49+
<h2 data-type="document-title">
50+
<span class="os-text">Chapter title</span>
51+
</h2>
52+
</div>
53+
</div>
54+
<div data-type="composite-page" class="os-eob">
55+
<h1 data-type="document-title">
56+
<span class="os-text">Index title</span>
57+
</h1><p class="folio-eob-right">Index title</p><p class="folio-eob-left">Index title</p>
58+
</div>
59+
60+
</body>
61+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<html xmlns:m="http://www.w3.org/1998/Math/MathML" data-pdf-folio-preface-message="Preface" data-pdf-folio-access-message="Access for free at openstax.org">
2+
<body>
3+
<div data-type="unit">
4+
<div data-type="chapter">
5+
<h1 data-type="document-title">
6+
<span class="os-text">Chapter title</span>
7+
</h1><p class="folio-chapter">
8+
1.1 &#x2022; Chapter title
9+
</p>
10+
<div data-type="page" class="introduction">
11+
<h2 data-type="document-title">
12+
<span class="os-text">Introduction title</span>
13+
</h2><p class="folio-module">
14+
1.1 &#x2022; Introduction title
15+
</p>
16+
</div>
17+
<div data-type="page">
18+
<h2 data-type="document-title">
19+
<span class="os-text">Module title</span>
20+
</h2><p class="folio-module">
21+
1.1.1 &#x2022; Module title
22+
</p>
23+
</div>
24+
<div data-type="composite-page" class="os-eoc">
25+
<h2 data-type="document-title">
26+
<span class="os-text">Eoc title</span>
27+
</h2><p class="folio-eoc-right">
28+
1.1 &#x2022; Eoc title
29+
</p><p class="folio-eoc-left">
30+
1.1 &#x2022; Eoc title
31+
</p>
32+
</div>
33+
</div>
34+
</div>
35+
<div data-type="page" class="appendix">
36+
<h1 data-type="document-title">
37+
<span class="os-text">Appendix title</span>
38+
</h1><p class="folio-appendix-right">
39+
A &#x2022; Appendix title
40+
</p><p class="folio-appendix-left">
41+
A &#x2022; Appendix title
42+
</p>
43+
</div>
44+
<div data-type="composite-chapter" class="os-eob os-solutions-container">
45+
<h1 data-type="document-title">
46+
<span class="os-text">Answer Key title</span>
47+
</h1><p class="folio-eob-right">Answer Key title</p><p class="folio-eob-left">Answer Key title</p>
48+
<div data-type="composite-page" class="os-eob os-solutions-container">
49+
<h2 data-type="document-title">
50+
<span class="os-text">Chapter title</span>
51+
</h2>
52+
</div>
53+
</div>
54+
<div data-type="composite-page" class="os-eob">
55+
<h1 data-type="document-title">
56+
<span class="os-text">Index title</span>
57+
</h1><p class="folio-eob-right">Index title</p><p class="folio-eob-left">Index title</p>
58+
</div>
59+
60+
</body>
61+
</html>

0 commit comments

Comments
 (0)