Fix unit test due to dependency update

pull/7449/head
John Niang 2025-05-19 18:04:02 +08:00
parent 0dd1e13e82
commit d64f01d0d5
No known key found for this signature in database
GPG Key ID: D7363C015BBCAA59
2 changed files with 14 additions and 11 deletions

View File

@ -36,7 +36,7 @@ class FileTypeDetectUtilsTest {
void detectMimeTypeWithNameTest() throws IOException { void detectMimeTypeWithNameTest() throws IOException {
var stream = getFileInputStream("classpath:file-type-detect/index.js"); var stream = getFileInputStream("classpath:file-type-detect/index.js");
String mimeType = FileTypeDetectUtils.detectMimeType(stream, "index.js"); String mimeType = FileTypeDetectUtils.detectMimeType(stream, "index.js");
assertThat(mimeType).isEqualTo("application/javascript"); assertThat(mimeType).isEqualTo("text/javascript");
stream = getFileInputStream("classpath:file-type-detect/index.html"); stream = getFileInputStream("classpath:file-type-detect/index.html");
mimeType = mimeType =

View File

@ -12,6 +12,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@ -106,11 +107,11 @@ class ContentTemplateHeadProcessorIntegrationTest {
.thenReturn(Mono.empty()); .thenReturn(Mono.empty());
lenient().when(applicationContext.getBeanProvider(ExtensionGetter.class)) lenient().when(applicationContext.getBeanProvider(ExtensionGetter.class))
.thenAnswer(invocation -> { .thenAnswer(invocation -> {
var objectProvider = mock(ObjectProvider.class); var objectProvider = mock(ObjectProvider.class);
when(objectProvider.getIfUnique()).thenReturn(extensionGetter); when(objectProvider.getIfUnique()).thenReturn(extensionGetter);
return objectProvider; return objectProvider;
}); });
lenient().when(extensionGetter.getExtensions(TemplateHeadProcessor.class)).thenReturn( lenient().when(extensionGetter.getExtensions(TemplateHeadProcessor.class)).thenReturn(
Flux.fromIterable(map.values()).sort(AnnotationAwareOrderComparator.INSTANCE) Flux.fromIterable(map.values()).sort(AnnotationAwareOrderComparator.INSTANCE)
); );
@ -145,7 +146,9 @@ class ContentTemplateHeadProcessorIntegrationTest {
2. global head meta is overridden by content head meta 2. global head meta is overridden by content head meta
3. but global head meta is not overridden by global seo meta 3. but global head meta is not overridden by global seo meta
*/ */
assertThat(Jsoup.parse(result).html()).isEqualTo(""" var outputSettings = new Document.OutputSettings().prettyPrint(true);
var actual = Jsoup.parse(result).outputSettings(outputSettings).html();
var expected = Jsoup.parse("""
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
@ -155,10 +158,10 @@ class ContentTemplateHeadProcessorIntegrationTest {
<meta name="description" content="post-description"> <meta name="description" content="post-description">
<meta name="other" content="post-other-meta"> <meta name="other" content="post-other-meta">
</head> </head>
<body> <body>this is body</body>
this is body </html>"""
</body> ).outputSettings(outputSettings).html();
</html>"""); assertThat(actual).isEqualTo(expected);
} }
Map<String, String> mutableMetaMap(String nameValue, String contentValue) { Map<String, String> mutableMetaMap(String nameValue, String contentValue) {