fix(epub): ignores non-publication dates for published metadata (#2226)
This commit is contained in:
+24
-2
@@ -307,14 +307,14 @@ class EpubMetadataExtractorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void fallsBackToDctermsModifiedWhenNoDate() throws IOException {
|
||||
void ignoresDctermsModifiedWhenNoDate() throws IOException {
|
||||
String opf = wrapOpf("""
|
||||
<dc:title>Book</dc:title>
|
||||
<meta property="dcterms:modified">2020-08-01T12:00:00Z</meta>
|
||||
""");
|
||||
BookMetadata metadata = extractor.extractMetadata(createEpub(opf));
|
||||
|
||||
assertThat(metadata.getPublishedDate()).isEqualTo(LocalDate.of(2020, 8, 1));
|
||||
assertThat(metadata.getPublishedDate()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -338,6 +338,28 @@ class EpubMetadataExtractorTest {
|
||||
|
||||
assertThat(metadata.getPublishedDate()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void usesPublicationDate() throws IOException {
|
||||
String opf = wrapOpf("""
|
||||
<dc:title>Book</dc:title>
|
||||
<dc:date opf:event="publication">2021-12-25T00:00:00</dc:date>
|
||||
""");
|
||||
BookMetadata metadata = extractor.extractMetadata(createEpub(opf));
|
||||
|
||||
assertThat(metadata.getPublishedDate()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void ignoresModificationDate() throws IOException {
|
||||
String opf = wrapOpf("""
|
||||
<dc:title>Book</dc:title>
|
||||
<dc:date opf:event="modification">2021-12-25T00:00:00</dc:date>
|
||||
""");
|
||||
BookMetadata metadata = extractor.extractMetadata(createEpub(opf));
|
||||
|
||||
assertThat(metadata.getPublishedDate()).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user