Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Add better testing for font mime types
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaupin committed Aug 19, 2019
1 parent 2d32174 commit 2a8f9fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 9 additions & 3 deletions epub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const (
testEpubPpd = "rtl"
testEpubTitle = "My title"
testEpubDescription = "My description"
testFontCSSFilename = "font.css"
testFontCSSSource = "testdata/font.css"
testFontFromFileSource = "testdata/redacted-script-regular.ttf"
testIdentifierTemplate = `<dc:identifier id="pub-id">%s</dc:identifier>`
testImageFromFileFilename = "testfromfile.png"
Expand Down Expand Up @@ -623,14 +625,18 @@ func TestUnableToCreateEpubError(t *testing.T) {

func TestEpubValidity(t *testing.T) {
e := NewEpub(testEpubTitle)
testCSSPath, _ := e.AddCSS(testCoverCSSSource, testCoverCSSFilename)
testCoverCSSPath, _ := e.AddCSS(testCoverCSSSource, testCoverCSSFilename)
e.AddCSS(testCoverCSSSource, "")
e.AddSection(testSectionBody, testSectionTitle, testSectionFilename, testCoverCSSPath)

e.AddFont(testFontFromFileSource, "")
e.AddSection(testSectionBody, testSectionTitle, testSectionFilename, testCSSPath)
// Add CSS referencing the font in order to validate the font MIME type
testFontCSSPath, _ := e.AddCSS(testFontCSSSource, testFontCSSFilename)
e.AddSection(testSectionBody, "", "", testFontCSSPath)

testImagePath, _ := e.AddImage(testImageFromFileSource, testImageFromFileFilename)
e.AddImage(testImageFromFileSource, testImageFromFileFilename)
e.AddImage(testImageFromURLSource, "")
e.AddSection(testSectionBody, "", "", "")
e.SetAuthor(testEpubAuthor)
e.SetCover(testImagePath, "")
e.SetDescription(testEpubDescription)
Expand Down
8 changes: 8 additions & 0 deletions testdata/font.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
p {
font-family: "Redacted Script", serif;
}

@font-face {
font-family: "Redacted Script";
src: url(../fonts/redacted-script-regular.ttf) format('truetype');
}

0 comments on commit 2a8f9fd

Please sign in to comment.